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_GeolocationPermissionManagerImpl.h"
92 #include "FWebCtrl_HitElementResultImpl.h"
93 #include "FWebCtrl_InputPickerPopup.h"
94 #include "FWebCtrl_WebNotification.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 result r = E_SUCCESS;
570 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
571 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
572 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
574 MessageBox messageBox;
575 r = messageBox.Construct(L"Notification request", L"Do you want to allow notifications from this site ?", MSGBOX_STYLE_OKCANCEL);
576 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
579 r = messageBox.ShowAndWait(modalResult);
580 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
582 if (modalResult == MSGBOX_RESULT_OK)
584 ewk_notification_permission_request_set(pPermissionRequest, EINA_TRUE);
588 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
594 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
596 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
597 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
598 SysAssertf(pImpl && pNotification, "Failed to request");
600 result r = E_SUCCESS;
601 Ewk_Context* pContext = ewk_view_context_get(pView);
602 SysAssertf(pContext, "Failed to get webkit instance.");
603 uint64_t notificationId = ewk_notification_id_get(pNotification);
605 //ewk_notification_security_origin_get(pNotification)
607 const char* text = ewk_notification_body_get(pNotification);
608 SysLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
610 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
611 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
613 r = pNotificationWindow->Construct(pContext, notificationId);
614 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
616 pNotificationWindow->SetText(String(text));
617 pNotificationWindow->LaunchNotification();
618 pNotificationWindow.release();
620 ewk_notification_showed(pContext, notificationId);
625 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
627 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
628 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
629 SysAssertf(pImpl && pNotificationID, "Failed to request");
631 //ToDo : Where is ewk API for cancel operation?
636 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
638 result r = E_SUCCESS;
639 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
640 SysAssertf(pImpl, "Failed to request");
642 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
643 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
648 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
650 int checkHandler = 0;
651 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
652 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
653 SysAssertf(pImpl && pHandlerData, "Failed to request");
655 checkHandler = pImpl->SearchHandler(pHandlerData, false);
656 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
657 switch (checkHandler)
662 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
665 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
668 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
676 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
678 result r = E_SUCCESS;
679 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
680 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
681 SysAssertf(pImpl && pHandlerData, "Failed to request");
683 r = pImpl->UnregistrationHandler(pHandlerData, false);
684 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
689 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
691 result r = E_SUCCESS;
692 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
693 SysAssertf(pImpl, "Failed to request");
695 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
696 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
701 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
703 int checkHandler = 0;
704 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
705 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
706 SysAssertf(pImpl && pHandlerData, "Failed to request");
708 checkHandler = pImpl->SearchHandler(pHandlerData, true);
709 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
711 switch (checkHandler)
716 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
719 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
722 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
730 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
732 result r = E_SUCCESS;
733 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
734 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
735 SysAssertf(pImpl && pHandlerData, "Failed to request");
737 r = pImpl->UnregistrationHandler(pHandlerData, true);
738 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
743 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
745 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
746 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
747 SysAssertf(pImpl && pPolicy, "Failed to request");
749 String url(ewk_policy_decision_url_get(pPolicy));
750 SysLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
752 if (url == L"about:blank")
754 ewk_policy_decision_use(pPolicy);
758 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
759 && !pImpl->IsRedirectRequested())
761 pImpl->SetCertificateRequested(false);
763 if (pImpl->GetTextSearchListener())
765 pImpl->DisableAsyncSearch();
768 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
769 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
771 switch (ewkNavigationType)
773 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
774 navigationType = WEB_NAVIGATION_LINK_CLICKED;
776 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
777 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
779 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
780 navigationType = WEB_NAVIGATION_BACKFORWARD;
782 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
783 navigationType = WEB_NAVIGATION_RELOAD;
785 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
786 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
788 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
789 navigationType = WEB_NAVIGATION_OTHER;
795 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
797 ewk_policy_decision_ignore(pPolicy);
803 String currentUrl(pImpl->GetUrl());
804 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
805 if (redirectUrl != L"")
807 pImpl->LoadUrl(redirectUrl);
808 ewk_policy_decision_ignore(pPolicy);
816 String uriScheme(uri.GetScheme());
817 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
819 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
821 ewk_policy_decision_ignore(pPolicy);
823 if (uriScheme == L"")
828 result r = E_SUCCESS;
830 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
832 if (uriScheme == L"rtsp")
834 eventType = WEB_EVENT_REQUEST_RTSP;
836 else if (uriScheme == L"mailto")
838 eventType = WEB_EVENT_REQUEST_EMAIL;
840 else if (uriScheme == L"tel")
842 eventType = WEB_EVENT_REQUEST_TEL;
844 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
846 eventType = WEB_EVENT_REQUEST_SMS;
848 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
850 eventType = WEB_EVENT_REQUEST_MMS;
853 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
854 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
856 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
857 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
863 ewk_policy_decision_use(pPolicy);
868 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
870 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
871 SysAssertf(pImpl, "Failed to request");
873 if (pImpl->GetLoadingListener())
875 result r = E_SUCCESS;
877 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
878 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
880 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
881 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
888 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
890 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
891 char* pTitle = reinterpret_cast< char* >(pEventInfo);
892 SysAssertf(pImpl, "Failed to request");
894 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
896 if (pImpl->GetLoadingListener())
898 result r = E_SUCCESS;
900 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
901 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
902 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
904 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
905 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
906 pPageTitle.release();
908 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
909 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
916 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
918 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
919 double* pProgress = reinterpret_cast< double* >(pEventInfo);
920 SysAssertf(pImpl, "Failed to request");
922 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
924 if (pImpl->GetLoadingListener())
926 result r = E_SUCCESS;
928 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
929 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
930 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
932 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
933 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
934 pProgressPercentage.release();
936 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
937 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
944 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
946 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
947 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
948 SysAssertf(pImpl && pPolicy, "Failed to request");
950 result r = E_SUCCESS;
952 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
953 int code = ewk_policy_decision_response_status_code_get(pPolicy);
954 String mime(ewk_policy_decision_response_mime_get(pPolicy));
955 SysLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
957 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
959 String url(ewk_policy_decision_url_get(pPolicy));
962 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
964 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
966 DecisionPolicy policy;
967 HttpHeader httpHeader;
969 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
971 pImpl->SetRedirectRequested(true);
975 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
976 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
978 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
979 pImpl->SetPolicyDecision(policy);
982 switch (pImpl->GetPolicyDecision())
984 case WEB_DECISION_CONTINUE:
986 String currentUrl(pImpl->GetUrl());
987 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
988 if (redirectUrl != L"")
990 pImpl->LoadUrl(redirectUrl);
991 ewk_policy_decision_ignore(pPolicy);
996 if (pImpl->IsMimeSupported(mime) || mime == L"")
1003 SysLog(NID_WEB_CTRL, "Launch native app to handle the mime");
1005 ewk_policy_decision_ignore(pPolicy);
1007 AppControl* pAppControl = null;
1008 _SelectBox selectBox;
1010 int selectedIndex = 0;
1012 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
1016 appCount = pList->GetCount();
1019 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
1020 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1022 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1023 for (int i = 0; i < appCount; i++)
1025 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
1026 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1028 String text = pAppControl->GetAppName();
1029 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
1031 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1033 r = selectBox.ShowAndWait(selectedIndex);
1034 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1036 if (selectedIndex == 0) //download
1038 RequestId reqId = 0;
1039 DownloadRequest request(pUrl);
1041 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1042 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1044 r = pManagerImpl->Start(request, reqId);
1045 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1047 else if (selectedIndex != -1) // -1 for cancel
1049 String path("path");
1050 String pathVal(pUrl);
1053 r = dataList.Construct();
1054 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1056 r = dataList.Add(path, pathVal);
1057 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1059 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
1060 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1062 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
1063 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1065 r = pAcImpl->Start(null, null, &dataList, null);
1066 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1073 case WEB_DECISION_DOWNLOAD:
1075 ewk_policy_decision_ignore(pPolicy);
1077 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1078 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1080 Ewk_Context* pContext = ewk_view_context_get(pView);
1081 SysAssertf(pContext, "Failed to get webkit instance.");
1083 pDownloadHandler->StartDownload(pUrl);
1087 case WEB_DECISION_IGNORE:
1089 ewk_policy_decision_ignore(pPolicy);
1099 ewk_policy_decision_use(pPolicy);
1104 ewk_policy_decision_ignore(pPolicy);
1109 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1111 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1112 SysAssertf(pImpl, "Failed to request");
1114 if (pImpl->IsRedirectRequested())
1116 pImpl->SetRedirectRequested(false);
1119 if (pImpl->IsLoadingErrorOccurred())
1121 pImpl->SetLoadingErrorOccurred(false);
1122 evas_object_smart_callback_call(pView, "load,finished", NULL);
1128 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1130 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1131 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1132 SysAssertf(pImpl && pErrorData, "Failed to request");
1134 int code = ewk_error_code_get(pErrorData);
1135 const char* pDescription = ewk_error_description_get(pErrorData);
1137 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1139 pImpl->SetLoadingErrorOccurred(true);
1142 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1144 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1147 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1148 evas_object_smart_callback_call(pView, "load,stop", NULL);
1152 if (pImpl->GetLoadingListener())
1154 result r = E_SUCCESS;
1156 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1157 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1165 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1167 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1168 SysAssertf(pImpl, "Failed to request");
1170 if (pImpl->GetLoadingListener())
1172 result r = E_SUCCESS;
1174 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1175 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1177 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1178 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1179 pEventArg.release();
1186 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1188 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1189 SysAssertf(pImpl, "Failed to request");
1191 if (pImpl->GetLoadingListener())
1193 result r = E_SUCCESS;
1195 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1196 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1198 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1199 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1200 pEventArg.release();
1207 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1209 evas_object_focus_set(pView, EINA_FALSE);
1214 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1216 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1217 SysAssertf(pImpl, "Failed to request");
1219 if (pImpl->GetLoadingListener())
1221 result r = E_SUCCESS;
1223 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1224 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1226 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1227 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1228 pEventArg.release();
1235 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1237 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1238 SysAssertf(pUrl && pImpl != null, "Failed to request");
1240 SysLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1245 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1247 result r = E_SUCCESS;
1249 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1250 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1252 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1253 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1254 pEventArg.release();
1261 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1263 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1264 SysAssertf(pImpl, "Failed to request");
1266 if (pImpl->GetUiEventListener())
1268 result r = E_SUCCESS;
1270 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1271 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1273 if (pImpl->GetUiEventListenerF())
1275 result r = E_SUCCESS;
1277 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1278 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1284 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1286 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1287 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1288 SysAssertf(pParentImpl && pChildView, "Failed to request");
1290 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1291 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1292 if (pUserUiListener)
1294 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1297 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1298 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1300 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1301 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1304 if (pUserUiListenerF)
1306 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1309 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1310 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1312 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1313 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1320 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1322 result r = E_SUCCESS;
1324 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1325 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1327 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1328 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1329 pEventArg.release();
1336 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1338 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1339 SysAssertf(pChildImpl, "Failed to request");
1341 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1342 if (pParentImpl == null)
1347 if (pParentImpl->GetUiEventListener())
1349 result r = E_SUCCESS;
1351 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1352 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1354 if (pParentImpl->GetUiEventListenerF())
1356 result r = E_SUCCESS;
1358 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1359 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1365 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1367 result r = E_SUCCESS;
1369 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1370 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1371 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1373 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1374 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1375 pPreventTrigger.release();
1377 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1378 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1379 pEventArg.release();
1386 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1388 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1389 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1390 SysAssertf(pImpl && pTrigger, "Failed to request");
1392 if (pImpl->GetUiEventListener())
1394 result r = E_SUCCESS;
1396 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1397 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1399 if (pImpl->GetUiEventListenerF())
1401 result r = E_SUCCESS;
1403 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1404 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1410 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1412 result r = E_SUCCESS;
1414 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1415 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1416 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1418 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1420 if ((endPoint->x != 0) && (endPoint->y != 0))
1422 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1423 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1425 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1426 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1427 startPoint.release();
1429 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1430 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1433 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1434 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1435 pEventArg.release();
1443 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1445 result r = E_SUCCESS;
1447 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1448 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1450 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1452 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1454 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1456 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1457 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1459 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1460 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1461 startPoint.release();
1463 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1464 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1467 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1468 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1469 pEventArg.release();
1477 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1479 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1480 Ewk_Text_Style* pStyle = reinterpret_cast< Ewk_Text_Style* >(pEventInfo);
1481 SysAssertf(pImpl && pStyle, "Failed to request");
1483 if (pImpl->GetUiEventListener())
1485 result r = E_SUCCESS;
1487 r = FireWebPageBlockSelectedEvent(pImpl);
1488 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1490 if (pImpl->GetUiEventListenerF())
1492 result r = E_SUCCESS;
1494 r = FireWebPageBlockSelectedEventF(pImpl);
1495 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1501 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1503 Eina_Bool ret = EINA_FALSE;
1504 Eina_List* pSelectedFileNames = null;
1505 String isMultipleSelection(L"single");
1509 isMultipleSelection.Append(L"multiple");
1512 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1513 SysTryCatch(NID_WEB_CTRL, pMediaListener.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1516 int itemCount = eina_list_count(pAcceptTypes);
1517 String fileType = L"all";
1521 String item((char*)eina_list_nth(pAcceptTypes, 0));
1522 if (item.StartsWith("image/",0))
1524 fileType = L"image";
1526 else if (item.StartsWith("audio/",0))
1528 fileType = L"audio";
1530 else if (item.StartsWith("video/",0))
1532 fileType = L"video";
1537 result r = dataList.Construct();
1538 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1540 String mode(L"selectionType");
1541 r = dataList.Add(mode, isMultipleSelection);
1542 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1544 String type(L"type");
1545 r = dataList.Add(type, fileType);
1546 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1548 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1549 SysTryCatch(NID_WEB_CTRL, pMediaAppControl.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1551 _AppControlImpl* pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl);
1552 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1553 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1557 if (pMediaListener->IsSelectionCompleted())
1559 const ArrayList* pSelectedFiles = pMediaListener->GetSelectedFiles();
1560 SysTryCatch(NID_WEB_CTRL, pSelectedFiles, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1562 int fileCount = pSelectedFiles->GetCount();
1564 for (int i = 0; i < fileCount; i++)
1566 String* pFile = (String*)pSelectedFiles->GetAt(i);
1567 SysTryCatch(NID_WEB_CTRL, pFile, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1569 std::unique_ptr<ByteBuffer> pByteBuf(StringUtil::StringToUtf8N(*pFile));
1570 SysTryCatch(NID_WEB_CTRL, pByteBuf.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1572 pSelectedFileNames = eina_list_append(pSelectedFileNames, strdup((const char*)pByteBuf->GetPointer()));
1579 ecore_main_loop_iterate();
1582 ewk_view_open_panel_reply(pView, pSelectedFileNames, ret);
1587 ewk_view_open_panel_reply(pView, null, ret);
1588 eina_list_free(pSelectedFileNames);
1594 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1596 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1597 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1598 SysAssertf(pImpl && pJsonText, "Failed to request");
1600 result r = E_SUCCESS;
1602 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1604 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1605 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1607 r = pEventArg->Construct(pJsonText);
1608 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1610 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1611 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1612 pEventArg.release();
1617 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1619 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1620 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1621 SysAssertf(pImpl && pEinaRect, "Failed to request");
1623 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1625 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1626 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1628 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1630 if (rect.height == 0)
1635 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1638 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1640 pImpl->SetFooterVisibleState(true);
1641 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1644 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1647 if (pImpl->GetWebKeypadEventListener())
1649 if (pImpl->IsKeypadVisible() == true)
1651 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1653 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1658 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1661 pImpl->SetKeypadVisibleState(true);
1662 pImpl->SetPreviousKeypadBounds(rect);
1666 result r = pImpl->SetFullScreenKeypad();
1667 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1673 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1675 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1676 SysAssertf(pImpl, "Failed to request");
1678 if (pImpl->GetWebKeypadEventListener())
1680 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1686 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1688 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1689 SysAssertf(pImpl, "Failed to request");
1691 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1694 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1696 pImpl->SetFooterVisibleState(false);
1697 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1700 pFormCore->DeflateClientRectHeight(0);
1703 if (pImpl->GetWebKeypadEventListener())
1705 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1708 pImpl->SetKeypadVisibleState(false);
1713 OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info)
1715 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1716 SysAssertf(pImpl, "Failed to request");
1718 if (pImpl->IsKeypadOpened() == true)
1720 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1721 SysAssertf(pWebCore, "Failed to get Web core object");
1723 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1725 pImpl->SetKeypadOpened(false);
1731 OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo)
1733 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1734 SysAssertf(pImpl, "Failed to request");
1736 if (pImpl->IsKeypadOpened() == true)
1738 pImpl->SetKeypadOpened(false);
1744 OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha)
1746 SysAssertf(pSmartData, "invalid smartdata");
1747 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1748 SysAssertf(pWebImpl, "Failed to get Impl");
1750 result r = E_SUCCESS;
1752 if (pWebImpl->GetColorpicker())
1759 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1760 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1762 byte r1, g1, b1, a1;
1763 color.GetColorComponents(r1, g1, b1, a1);
1764 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1771 OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData)
1773 SysAssertf(pSmartData, "invalid smartdata");
1775 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1776 SysAssertf(pWebImpl, "Failed to get Impl");
1778 return pWebImpl->HideColorPicker();
1783 OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1785 SysAssertf(pSmartData, "Failed to request");
1786 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1787 SysAssertf(pWebImpl, "Failed to get Impl");
1789 result r = E_SUCCESS;
1791 if (pWebImpl->GetDatepicker())
1793 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1800 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1801 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1803 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1804 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1806 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1813 OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1815 SysAssertf(pSmartData, "Failed to request");
1817 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1818 SysAssertf(pWebImpl, "Failed to get Impl");
1820 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1821 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1828 OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData)
1830 SysAssertf(pSmartData, "invalid smartdata");
1832 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1833 SysAssertf(pWebImpl, "Failed to get Impl");
1835 result r = pWebImpl->ClearSelectBoxPopup();
1836 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1843 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1845 SysAssertf(pSmartData, "invalid smartdata");
1847 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1848 SysAssertf(pWebImpl, "Failed to get Impl");
1850 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1851 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1858 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1860 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1861 SysAssertf(pPresenter && !pError, "Failed to request");
1863 bool ret = EINA_TRUE;
1867 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1869 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1873 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1882 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1884 pPresenter->EndAsyncProcess(ret);
1889 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1891 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1892 SysAssertf(pPresenter, "Failed to request");
1894 String result(pResult);
1895 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1897 pPresenter->EndAsyncProcess(result);
1902 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
1904 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1905 SysAssertf(pImpl, "Failed to request");
1907 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
1908 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
1910 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
1914 pWebPresenter->EndAsyncProcess(*pTotalCount);
1918 if (pImpl->GetTextSearchListener())
1920 result r = E_SUCCESS;
1924 if (*pTotalCount > 0)
1926 ordinal = pImpl->GetAsyncSearchOrdinal();
1927 pImpl->SetAsyncSearchResult(*pTotalCount);
1930 if (pImpl->GetPendingAsyncSearchCount() > 0)
1935 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
1936 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
1937 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
1938 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1940 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
1941 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1944 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
1945 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1948 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1949 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1950 pEventArg.release();
1956 class _JsBridgeHashCodeProvider
1957 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
1960 _JsBridgeHashCodeProvider(){}
1961 virtual ~_JsBridgeHashCodeProvider(void) {}
1964 int GetHashCode(const Tizen::Base::String& obj) const
1966 return obj.GetHashCode();
1972 //Comparer implementation
1973 class _JsBridgeComparer
1974 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
1977 _JsBridgeComparer(){}
1978 virtual ~_JsBridgeComparer(void) {}
1981 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
1998 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
1999 : _ContainerImpl(pWeb, pCore)
2000 , __isFooterVisible(false)
2001 , __isKeypadVisible(false)
2002 , __isKeypadOpened(false)
2003 , __isLoadingErrorOccurred(false)
2004 , __isRedirectRequested(false)
2005 , __isCertificateRequested(false)
2006 , __isCertificateConfirmed(false)
2007 , __keypadBounds(0, 0, 0, 0)
2009 , __pUserLoadingListener(null)
2010 , __pUserUiListener(null)
2011 , __pUserUiListenerF(null)
2012 , __pUserKeypadEventListener(null)
2013 , __pTextSearchListener(null)
2015 , __pJsBridgeList(null)
2016 , __pJsProvider(null)
2017 , __pJsComparer(null)
2018 , __pWebDownloadHandler(null)
2020 , __pAuthChallenge(null)
2021 , __pAuthPopup(null)
2022 , __pUserConfirmPopup(null)
2023 , __pCertConfirmPopup(null)
2024 , __pSelectBox(null)
2025 , __pDatePicker(null)
2026 , __pColorPicker(null)
2027 , __policy(WEB_DECISION_CONTINUE)
2029 __textSearch.__searchAll = false;
2030 __textSearch.__searchForward = true;
2031 __textSearch.__caseSensitive = false;
2032 __textSearch.__pending = 0;
2033 __textSearch.__currentIndex = 1;
2034 __textSearch.__totalCount = -1;
2035 __textSearch.__text = L"";
2039 _WebImpl::~_WebImpl()
2041 RemoveEventListenerCallback();
2045 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2047 result r = E_SUCCESS;
2049 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2050 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2052 _Web* pCore = _Web::CreateWebN();
2053 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2055 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2057 r = CheckConstruction(pCore, pImpl);
2058 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2060 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2061 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2063 r = pImpl->Construct();
2064 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2076 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2078 result r = E_SUCCESS;
2080 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2081 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2083 _Web* pCore = _Web::CreateWebN();
2084 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2086 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2088 r = CheckConstruction(pCore, pImpl);
2089 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2091 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2092 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2094 r = pImpl->Construct();
2095 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2107 _WebImpl::Construct(void)
2109 result r = E_SUCCESS;
2111 r = __mutex.Create();
2112 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2114 r = __textSearch.__searchQueue.Construct();
2115 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2117 r = InitJsBridgeList();
2118 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2121 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2123 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2124 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2131 _WebImpl::InitializeSetting(void)
2133 result r = E_SUCCESS;
2135 r = SetSetting(*__pWebCore->GetSetting());
2136 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2138 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2140 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2141 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2142 SetZoomLevel(pWebSettingImpl->GetZoomLevel());
2144 SetEventListenerCallback();
2151 _WebImpl::IsLayoutable(void) const
2158 _WebImpl::InitWebEvent(void)
2160 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2161 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2163 return __pWebEvent->Construct(*this);
2168 _WebImpl::GetWebEvent(void) const
2170 return __pWebEvent.get();
2175 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2177 Eina_Hash* pHttpHeader = null;
2179 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2180 if (pFieldNameList.get())
2182 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2183 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2185 int count = pFieldNameList->GetCount();
2187 for (int i = 0; i < count; i++)
2189 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2190 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2192 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2193 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2195 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2196 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2198 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2200 Eina_Bool ret = false;
2202 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2203 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2205 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2206 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2208 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2209 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2216 eina_hash_free(pHttpHeader);
2223 _WebImpl::LoadUrl(const String& url) const
2225 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2226 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2228 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2235 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2237 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2238 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2240 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2242 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2244 eina_hash_free(pHttpHeader);
2251 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2253 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2254 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2256 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2258 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2260 eina_hash_free(pHttpHeader);
2267 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2269 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2271 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2272 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2273 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2274 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2276 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2283 _WebImpl::Pause(void)
2285 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2290 _WebImpl::Resume(void)
2292 ewk_view_resume(__pWebCore->GetWebNativeNode());
2297 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2299 __pSelectBox.reset();
2301 int itemCount = eina_list_count(pItems);
2302 SysTryReturnResult(NID_WEB_CTRL, itemCount > 0, E_SYSTEM, "ItemCount is invalid.");
2304 result r = E_SUCCESS;
2306 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2307 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2309 r = pSelectBox->Construct(isMultiSelect, title, itemCount, pWebView);
2310 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2312 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2313 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2315 __pSelectBox = std::move(pSelectBox);
2317 return __pSelectBox->ShowPopup();
2322 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2324 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2326 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2331 _WebImpl::ClearSelectBoxPopup(void)
2333 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2335 __pSelectBox.reset();
2342 _WebImpl::GetDatepicker(void)
2344 _InputPickerPopup* pInputPicker =null;
2347 pInputPicker = __pDatePicker.get();
2349 return pInputPicker;
2354 _WebImpl::GetColorpicker(void)
2356 _InputPickerPopup* pInputPicker =null;
2359 pInputPicker = __pColorPicker.get();
2361 return pInputPicker;
2366 _WebImpl::CanGoBack(void) const
2368 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2373 _WebImpl::CanGoForward(void) const
2375 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2380 _WebImpl::GoBack(void) const
2382 ewk_view_back(__pWebCore->GetWebNativeNode());
2387 _WebImpl::GoForward(void) const
2389 ewk_view_forward(__pWebCore->GetWebNativeNode());
2394 _WebImpl::GetUrl(void) const
2396 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2401 _WebImpl::GetTitle(void) const
2403 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2408 _WebImpl::StopLoading(void) const
2410 ewk_view_stop(__pWebCore->GetWebNativeNode());
2415 _WebImpl::Reload(void) const
2417 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
2422 _WebImpl::EvaluateJavascriptN(const String& scriptCode) const
2424 if (scriptCode.GetLength())
2426 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2427 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2429 _WebPresenter presenter;
2430 presenter.InitAsyncProcess();
2432 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, &presenter);
2434 Tizen::Base::String* pResult = new (std::nothrow) Tizen::Base::String(L"");
2435 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2436 presenter.WaitAsyncProcess(*pResult);
2446 _WebImpl::SetZoomLevel(float level)
2448 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);
2450 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2457 _WebImpl::GetZoomLevel(void) const
2459 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2463 const PageNavigationList*
2464 _WebImpl::GetBackForwardListN(void) const
2466 result r = E_SUCCESS;
2468 _PageNavigationListImpl* pNavigationListImpl = null;
2469 _HistoryItemImpl* pHistoryItemImpl = null;
2471 std::unique_ptr<PageNavigationList> pNavigationList;
2472 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2475 int forwardCount = 0;
2480 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2481 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2483 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2484 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2486 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2487 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2489 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2490 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2492 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2493 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2495 r = pHistoryList->Construct();
2496 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2498 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2499 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2500 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2502 for (int i = -backCount; i < forwardCount + 1; i++)
2504 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2505 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2507 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2508 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2510 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2511 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2513 url = ewk_history_item_uri_get(pEwkItem);
2514 title = ewk_history_item_title_get(pEwkItem);
2515 SysLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2517 pHistoryItemImpl->SetHistoryItem(url, title);
2519 r = pHistoryList->Add(*pHistoryItem.get());
2520 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2521 pHistoryItem.release();
2524 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2526 ewk_history_free(pEwkHistoryList);
2528 return pNavigationList.release();
2531 ewk_history_free(pEwkHistoryList);
2538 _WebImpl::SearchText(const String& text, bool searchForward)
2540 result r = E_SUCCESS;
2542 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2546 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2549 _WebPresenter presenter;
2550 presenter.InitAsyncProcess();
2552 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2553 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2556 presenter.WaitAsyncProcess(result);
2558 return static_cast < bool >(result);
2563 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2565 result r = E_SUCCESS;
2567 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2571 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2574 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2575 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2582 _WebImpl::SearchNextAsync(bool searchForward)
2584 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2585 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2586 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2588 result r = E_SUCCESS;
2590 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2592 if (__textSearch.__caseSensitive)
2594 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2599 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2602 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2603 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2610 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2612 MutexGuard lock(__mutex);
2614 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2615 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2620 if (__textSearch.__searchAll)
2622 DisableAsyncSearch();
2624 __textSearch.__searchQueue.Enqueue(this);
2625 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2627 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2628 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2632 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2634 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2638 case SEARCH_ALL_ASYNC:
2639 __textSearch.__searchAll = true;
2640 __textSearch.__text = text;
2641 __textSearch.__searchForward = true;
2642 __textSearch.__caseSensitive = caseSensitive;
2643 __textSearch.__totalCount = -1;
2644 __textSearch.__currentIndex = 1;
2646 __textSearch.__searchQueue.Enqueue(this);
2647 __textSearch.__searchQueue.Enqueue(this);
2649 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2650 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2653 case SEARCH_NEXT_ASYNC:
2654 __textSearch.__searchForward = searchForward;
2656 CalculateAsyncSearchOrdinal();
2658 __textSearch.__searchQueue.Enqueue(this);
2660 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2672 _WebImpl::SetAsyncSearchResult(int totalCount)
2674 __textSearch.__totalCount = totalCount;
2679 _WebImpl::GetSearchPresenter(void)
2681 MutexGuard lock(__mutex);
2683 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2688 _WebImpl::GetPendingAsyncSearchCount(void) const
2690 return __textSearch.__searchQueue.GetCount();
2695 _WebImpl::CalculateAsyncSearchOrdinal(void)
2697 if (__textSearch.__searchForward)
2699 __textSearch.__currentIndex++;
2703 __textSearch.__currentIndex--;
2709 _WebImpl::GetAsyncSearchOrdinal(void) const
2711 return __textSearch.__currentIndex;
2716 _WebImpl::DisableAsyncSearch(void)
2718 __textSearch.__searchAll = false;
2723 _WebImpl::SetSetting(const WebSetting& setting)
2725 if (__pWebCore->GetWebNativeNode())
2727 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2728 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2729 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2731 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2732 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2734 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2736 switch (setting.GetCacheControl())
2738 case WEB_CACHE_VALIDATED:
2739 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2742 case WEB_CACHE_IGNORE:
2743 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2750 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2752 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2756 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2759 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2761 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2763 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2765 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2766 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2768 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2770 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2772 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2774 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2776 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2779 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2781 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2782 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2783 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2784 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2785 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2786 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2787 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2788 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2789 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2790 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2791 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2792 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2793 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2800 _WebImpl::GetSetting(void) const
2802 return *__pWebCore->GetSetting();
2806 const HitElementResult*
2807 _WebImpl::GetElementByPointN(const Point& point) const
2809 result r = E_SUCCESS;
2811 _HitElementResultImpl* pHitElementResultImpl = null;
2813 std::unique_ptr<HitElementResult> pHitElementResult;
2814 std::unique_ptr<Bitmap> pImage;
2815 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2817 Point absPoint(__pWebCore->GetAbsoluteCoordinate(point));
2819 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2820 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2822 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2823 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2824 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2825 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2826 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2828 SysLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2830 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2831 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2833 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2834 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2836 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
2842 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
2843 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
2844 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
2845 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
2847 r = buf.Construct(imageLength);
2848 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2850 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
2851 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2855 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
2856 // webkit support types such as ico and vp8 additionally
2857 if (strcmp(pExtension, "gif") == 0)
2859 format = IMG_FORMAT_GIF;
2861 else if (strcmp(pExtension, "jpg") == 0)
2863 format = IMG_FORMAT_JPG;
2865 else if (strcmp(pExtension, "png") == 0)
2867 format = IMG_FORMAT_PNG;
2869 else if (strcmp(pExtension, "bmp") == 0)
2871 format = IMG_FORMAT_BMP;
2875 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
2879 r = image.Construct();
2880 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2882 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
2883 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2888 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
2889 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2891 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
2892 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2894 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
2895 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2898 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
2900 ewk_hit_test_free(pEwkHitTest);
2902 return pHitElementResult.release();
2905 ewk_hit_test_free(pEwkHitTest);
2911 const HitElementResult*
2912 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2914 const Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
2916 std::unique_ptr<const HitElementResult> pHitElementResult(GetElementByPointN(integerPoint));
2917 SysTryReturn(NID_WEB_CTRL, pHitElementResult.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2919 return pHitElementResult.release();
2924 _WebImpl::IsLoading(void) const
2926 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
2928 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
2940 _WebImpl::GetTextFromBlock(void) const
2942 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
2947 _WebImpl::IsPrivateBrowsingEnabled(void) const
2949 if (__pWebCore->GetWebNativeNode() == null)
2951 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
2954 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2955 SysAssertf(pSettings, "Failed to get webkit instance.");
2957 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
2962 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
2964 if (__pWebCore->GetWebNativeNode() == null)
2966 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
2970 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2971 SysAssertf(pSettings, "Failed to get webkit instance.");
2973 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
2978 _WebImpl::ClearHistory(void)
2980 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
2985 _WebImpl::ClearCache(void)
2987 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2988 SysAssertf(pContext, "Failed to get webkit instance.");
2990 ewk_context_cache_clear(pContext);
2995 _WebImpl::ClearCookie(void)
2997 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2998 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2999 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3001 ewk_cookie_manager_cookies_clear(pCookieManager);
3006 _WebImpl::ClearFormData(void)
3008 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3009 SysAssertf(pContext, "Failed to get webkit instance.");
3011 ewk_context_form_candidate_data_clear(pContext);
3016 _WebImpl::ClearLoginFormData(void)
3018 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3019 SysAssertf(pContext, "Failed to get webkit instance.");
3021 ewk_context_form_password_data_clear(pContext);
3026 _WebImpl::IsCookieEnabled(void) const
3028 if (__pWebCore->GetWebNativeNode() == null)
3030 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3033 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3034 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3035 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3037 _WebPresenter presenter;
3038 presenter.InitAsyncProcess();
3040 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3042 bool result = false;
3043 presenter.WaitAsyncProcess(result);
3050 _WebImpl::SetCookieEnabled(bool enable)
3052 if (__pWebCore->GetWebNativeNode() == null)
3054 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3059 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3060 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3061 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3065 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY);
3069 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3070 ewk_cookie_manager_cookies_clear(pCookieManager);
3076 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3078 result r = E_SUCCESS;
3080 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3081 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3084 String fileExtension = File::GetFileExtension(filePath);
3085 int pathLength = filePath.GetLength();
3088 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3090 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3091 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3092 r = filePath.SubString(0, index + 1, dirPath);
3093 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3095 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3096 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3100 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3102 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3106 Evas_Coord contentsWidth;
3107 Evas_Coord contentsHeight;
3109 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3110 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3118 _WebImpl::IsMimeSupported(const String& mime) const
3120 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3121 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3123 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3128 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3130 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3135 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3137 __pUserUiListener = pUiEventListener;
3142 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3144 __pUserUiListenerF = pUiEventListener;
3149 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3151 __pUserKeypadEventListener = pKeypadEventListener;
3156 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3158 if (__pWebDownloadHandler.get() == null)
3160 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3161 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3164 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3165 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3170 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3172 __pTextSearchListener = pTextSearchListener;
3177 _WebImpl::SetScrollEnabled(bool enable)
3179 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3184 _WebImpl::IsScrollEnabled(void) const
3186 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3191 _WebImpl::InitJsBridgeList(void)
3193 result r = E_SUCCESS;
3195 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3196 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3198 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3199 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3201 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3202 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3204 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3205 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3207 __pJsBridgeList = std::move(pJsBridgeList);
3214 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3216 result r = E_SUCCESS;
3218 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3219 String key(pJsBridge->GetName());
3221 r = __pJsBridgeList->Add(key, pJsBridge);
3222 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3229 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3231 result r = E_SUCCESS;
3233 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3234 String key(pJsBridge->GetName());
3236 r = __pJsBridgeList->Remove(key);
3237 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3244 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3246 result r = E_SUCCESS;
3248 IJsonValue* pJsonValue = null;
3249 IJavaScriptBridge* pJsBridge = null;
3251 String key(L"name");
3253 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3254 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));
3256 r = pJsonObject->GetValue(&key, pJsonValue);
3257 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3259 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3260 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3262 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3263 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3270 _WebImpl::GetLoadingListener(void) const
3272 return __pUserLoadingListener;
3276 IWebUiEventListener*
3277 _WebImpl::GetUiEventListener(void) const
3279 return __pUserUiListener;
3283 IWebUiEventListenerF*
3284 _WebImpl::GetUiEventListenerF(void) const
3286 return __pUserUiListenerF;
3290 IWebKeypadEventListener*
3291 _WebImpl::GetWebKeypadEventListener(void) const
3293 return __pUserKeypadEventListener;
3297 ITextSearchListener*
3298 _WebImpl::GetTextSearchListener(void) const
3300 return __pTextSearchListener;
3305 _WebImpl::SetEventListenerCallback(void) const
3307 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3310 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3311 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3313 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3314 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3316 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3317 SysAssertf(pSmartData, "Failed to request");
3319 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3320 SysAssertf(pSmart, "Failed to request");
3322 pSmart->popup_menu_show = OnSelectBoxRequested;
3323 pSmart->popup_menu_hide = OnSelectBoxClosed;
3324 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3326 pSmart->input_picker_show = OnDatePickerProviderRequested;
3327 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3328 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3330 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3332 // add loading event callbacks for ILoadingListener
3333 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3334 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3336 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3337 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3338 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3339 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3340 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3341 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3342 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3343 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3344 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3346 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3348 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3350 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3351 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3352 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3354 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3355 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3357 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3359 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3360 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3361 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3363 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3365 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3366 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3367 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3369 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3370 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3371 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3373 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3374 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3375 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3377 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3378 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3379 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3380 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3382 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3383 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3385 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3387 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3388 SysAssertf(pContext, "Failed to get webkit instance.");
3389 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3390 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3392 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3398 _WebImpl::RemoveEventListenerCallback(void) const
3400 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3403 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3404 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3406 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3407 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3409 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3410 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3412 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3413 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3414 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3415 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3416 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3417 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3418 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3419 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3421 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3423 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3425 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3426 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3427 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3429 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3430 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3432 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3434 ewk_view_javascript_alert_callback_set(null, null, null);
3435 ewk_view_javascript_prompt_callback_set(null, null, null);
3436 ewk_view_javascript_confirm_callback_set(null, null, null);
3438 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3440 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3441 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3442 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3444 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3445 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3446 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3447 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3448 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3449 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3451 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3452 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3453 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3455 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3457 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3458 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3460 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3462 ewk_view_open_panel_callback_set(null, null, null);
3464 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3470 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3472 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3474 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3475 SysAssertf(pSmartData, "Failed to request");
3477 Point absPoint(__pWebCore->GetAbsoluteCoordinate(startPoint));
3479 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3482 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3484 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3485 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3487 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3489 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3491 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3495 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3502 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3504 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToInteger(startPoint));
3509 _WebImpl::ReleaseBlock(void)
3511 ewk_view_command_execute(__pWebCore->GetWebNativeNode(), "Unselect", 0);
3516 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3518 FloatPoint tempStartPoint;
3519 FloatPoint tempEndPoint;
3521 GetBlockRange(tempStartPoint, tempEndPoint);
3523 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3524 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3529 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3531 Eina_Rectangle leftHandle;
3532 Eina_Rectangle rightHandle;
3534 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3536 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3537 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3538 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3539 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3541 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3543 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3544 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3550 _WebImpl::GetFaviconN(void) const
3552 result r = E_SUCCESS;
3554 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3556 Evas* pEvas = evas_object_evas_get(pView);
3557 Ewk_Context* pContext = ewk_view_context_get(pView);
3558 SysAssertf(pEvas && pContext, "Failed to request");
3560 const char* pUrl = ewk_view_url_get(pView);
3562 Tizen::Graphics::BufferInfo bufferInfo;
3563 Tizen::Base::ByteBuffer byteBuffer;
3565 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3566 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3568 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3574 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3575 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3577 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3579 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3580 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3582 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3583 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3585 return pBitmapImage.release();
3591 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3593 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3598 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3600 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3605 _WebImpl::GetScrollPosition(void) const
3609 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3616 _WebImpl::GetPageSize(void) const
3618 Evas_Coord width = 0;
3619 Evas_Coord height = 0;
3621 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3623 Dimension size(static_cast< int >(width), static_cast< int >(height));
3630 _WebImpl::SetLoadingErrorOccurred(bool arg)
3632 __isLoadingErrorOccurred = arg;
3637 _WebImpl::IsLoadingErrorOccurred(void) const
3639 return __isLoadingErrorOccurred;
3644 _WebImpl::SetRedirectRequested(bool arg)
3646 __isRedirectRequested = arg;
3651 _WebImpl::IsRedirectRequested(void) const
3653 return __isRedirectRequested;
3658 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3665 _WebImpl::GetPolicyDecision(void) const
3672 _WebImpl::SetCertificateRequested(bool arg)
3674 __isCertificateRequested = arg;
3679 _WebImpl::IsCertificateRequested(void) const
3681 return __isCertificateRequested;
3686 _WebImpl::IsCertificateConfirmed(void) const
3688 return __isCertificateConfirmed;
3693 _WebImpl::LaunchAppControl(const IEventArg& arg)
3695 result r = E_SUCCESS;
3697 IEventArg* pArg = const_cast< IEventArg* >(&arg);
3698 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
3699 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
3701 String operationId(L"");
3702 String uriPattern(pWebEventArg->GetEventMessage());
3703 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
3705 switch (pWebEventArg->GetEventType())
3707 case WEB_EVENT_REQUEST_RTSP:
3711 int uriLength = uriPattern.GetLength();
3714 operationId = L"http://tizen.org/appcontrol/operation/view";
3716 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
3717 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3719 r = uriPattern.SubString(index + 1, ext);
3720 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3722 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
3723 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3725 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
3726 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3730 case WEB_EVENT_REQUEST_TEL:
3732 operationId = L"http://tizen.org/appcontrol/operation/dial";
3735 case WEB_EVENT_REQUEST_EMAIL:
3737 case WEB_EVENT_REQUEST_SMS:
3739 case WEB_EVENT_REQUEST_MMS:
3741 operationId = L"http://tizen.org/appcontrol/operation/compose";
3744 case WEB_EVENT_REQUEST_UNKNOWN:
3746 operationId = L"http://tizen.org/appcontrol/operation/view";
3754 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
3755 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3762 _WebImpl::SetFullScreenKeypad(void)
3764 result r = E_SUCCESS;
3766 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3767 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3769 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3770 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3772 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3773 pKeypad->SetText(text);
3775 r = pKeypad->SetShowState(true);
3776 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3778 r = pKeypad->Show();
3779 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3781 pKeypad->AddTextEventListener(*this);
3783 __pKeypad = std::move(pKeypad);
3790 _WebImpl::RemoveFullScreenKeypad(void)
3792 __pKeypad->RemoveTextEventListener(*this);
3799 _WebImpl::IsFooterVisible(void) const
3801 return __isFooterVisible;
3806 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3808 __isFooterVisible = isFooterVisible;
3813 _WebImpl::IsKeypadVisible(void) const
3815 return __isKeypadVisible;
3820 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3822 __isKeypadVisible = isKeypadVisible;
3827 _WebImpl::IsKeypadOpened(void) const
3829 return __isKeypadOpened;
3833 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
3835 __isKeypadOpened = isKeypadOpened;
3840 _WebImpl::GetPreviousKeypadBounds(void) const
3842 return __keypadBounds;
3847 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
3849 __keypadBounds = bounds;
3854 _WebImpl::OnTextValueChangeCanceled(const Control& source)
3856 RemoveFullScreenKeypad();
3861 _WebImpl::OnTextValueChanged(const Control& source)
3863 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
3865 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
3867 RemoveFullScreenKeypad();
3872 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
3874 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
3875 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
3877 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
3878 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3880 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
3881 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
3883 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
3890 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
3892 result r = E_SUCCESS;
3894 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
3895 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3897 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3899 ILoadingListener* pLoadingListner = GetLoadingListener();
3900 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
3902 switch (pEventArg->GetEventType())
3904 case WEB_EVENT_LOADINGLISTENER_STARTED:
3906 pLoadingListner->OnLoadingStarted();
3910 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
3912 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
3913 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3915 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
3919 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
3921 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
3922 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3924 pLoadingListner->OnPageTitleReceived(*pPageTitle);
3928 case WEB_EVENT_LOADINGLISTENER_CANCELED:
3930 pLoadingListner->OnLoadingCanceled();
3934 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
3936 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
3937 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3939 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
3940 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3942 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
3944 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
3948 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
3950 pLoadingListner->OnLoadingCompleted();
3954 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
3956 pLoadingListner->OnHttpAuthenticationCanceled();
3960 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
3962 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
3963 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3967 pLoadingListner->OnFaviconReceived(*pFavicon.get());
3983 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
3985 result r = E_SUCCESS;
3987 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
3988 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3990 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3992 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
3993 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
3995 switch (pEventArg->GetEventType())
3997 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
3999 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4000 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4002 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4006 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4008 pWebDownloadListener->OnWebDataDownloadCompleted();
4012 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4014 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4015 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4017 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4019 pWebDownloadListener->OnWebDownloadFailed(errorType);
4034 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4036 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4037 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4039 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4041 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4043 switch (pEventArg->GetEventType())
4045 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4047 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4049 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4050 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4052 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4053 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4055 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4059 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4061 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4063 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4067 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4069 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4071 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4075 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4077 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4079 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4080 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4082 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4097 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4099 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4100 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4102 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4104 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4106 switch (pEventArg->GetEventType())
4108 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4110 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4112 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4113 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4115 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4116 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4118 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4122 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4124 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4126 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4130 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4132 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4134 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4138 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4140 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4142 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4143 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4145 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4160 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4162 result r = E_SUCCESS;
4164 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4165 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4167 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4169 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4170 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4172 switch (pEventArg->GetEventType())
4174 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4176 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4177 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4179 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4180 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4182 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4197 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4199 result r = E_SUCCESS;
4201 String host(ewk_auth_challenge_url_get(pChallenge));
4202 String realm(ewk_auth_challenge_realm_get(pChallenge));
4204 __pAuthChallenge.reset();
4206 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4207 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4209 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4210 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4212 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4213 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4215 __pAuthChallenge = std::move(pAuthChallenge);
4217 ewk_auth_challenge_suspend(pChallenge);
4218 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4220 __pAuthChallenge.release();
4224 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4225 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4233 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4235 result r = E_SUCCESS;
4237 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4238 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4240 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4241 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4243 __pAuthPopup = std::move(pAuthPopup);
4245 int modalResult = 0;
4246 r = __pAuthPopup->ShowAndWait(modalResult);
4247 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4250 __pAuthPopup.reset();
4257 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4259 result r = E_SUCCESS;
4261 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4262 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4264 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4265 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4267 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4269 int modalResult = 0;
4270 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4271 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4273 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4275 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4279 __pCertConfirmPopup.reset();
4285 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy)
4287 result r = E_SUCCESS;
4289 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4290 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4292 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true);
4293 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4295 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4297 int modalResult = 0;
4298 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4299 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4302 __pUserConfirmPopup.reset();
4308 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy)
4310 result r = E_SUCCESS;
4312 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4313 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4315 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false);
4316 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4318 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4320 r = __pUserConfirmPopup->ShowPopup();
4321 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4323 __pUserConfirmPopup.release();
4328 __pUserConfirmPopup.reset();
4335 _WebImpl::GetParentFormCore(_Control* pControlCore)
4338 _Form* pFormCore = null;
4340 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4341 if (!pParentControlCore)
4346 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4352 return GetParentFormCore(pParentControlCore);
4357 _WebImpl::OnFocusGained(const _ControlImpl& source)
4364 _WebImpl::OnFocusLost(const _ControlImpl& source)
4366 if(IsKeypadVisible() == true)
4368 SetKeypadOpened(true);
4370 SetKeypadVisibleState(false);
4373 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4380 _WebImpl::HasValidNativeNode(void) const
4382 if (__pWebCore && __pWebCore->GetWebNativeNode())
4392 _WebImpl::OnAttachedToMainTree(void)
4394 result r = E_SUCCESS;
4396 r = __pWebCore->InitializeWebNativeNode();
4397 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4399 r = InitializeSetting();
4400 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4402 r = _ContainerImpl::OnAttachedToMainTree();
4403 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4410 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4412 _ContainerImpl::OnChangeLayout(orientation);
4414 if (__pColorPicker.get())
4416 __pColorPicker->ChangeLayout(orientation);
4422 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4424 if (IsVisible() == true)
4426 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4430 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4436 _WebImpl::GetDownloadHandler(void) const
4438 return __pWebDownloadHandler.get();
4443 _WebImpl::HideColorPicker(void)
4445 __pColorPicker.reset();
4452 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4454 result r = E_SUCCESS;
4456 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4457 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4459 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4461 r = pColorHadler->Construct(colorVal);
4462 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4464 __pColorPicker = std::move(pColorHadler);
4466 r = __pColorPicker->ShowPopup();
4467 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4469 color = __pColorPicker->GetColor();
4474 __pColorPicker.reset();
4481 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4483 result r = E_SUCCESS;
4485 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4486 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4488 r = pInputPicker->Construct(String(inputValue), inputType);
4489 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4491 __pDatePicker = std::move(pInputPicker);
4493 r = __pDatePicker->ShowPopup();
4494 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4496 dateStr = __pDatePicker->GetDate();
4499 __pDatePicker.reset();
4506 _WebImpl::GetInstance(Web* pWeb)
4508 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4513 _WebImpl::GetInstance(const Web* pWeb)
4515 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4520 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4522 int checkReturn = 0;
4524 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4527 if( checkmime == true)
4529 table = CUSTOM_CONTENT_TABLE_NAME;
4533 table = CUSTOM_PROTOCOL_TABLE_NAME;
4536 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4537 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4538 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4540 SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4542 result r = db.Construct(handlerPath, "r+", null);
4543 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4545 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
4546 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4550 r = pEnum->MoveNext();
4551 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4552 r = pEnum->GetIntAt(0, checkReturn);
4553 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4565 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4569 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4572 if( checkmime == true)
4574 table = CUSTOM_CONTENT_TABLE_NAME;
4578 table = CUSTOM_PROTOCOL_TABLE_NAME;
4581 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4582 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4583 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4585 SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4587 result r = db.Construct(handlerPath, "r+", null);
4588 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4590 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select id From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
4591 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4595 r = pEnum->MoveNext();
4596 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4597 r = pEnum->GetIntAt(0, checkId);
4598 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4600 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
4601 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4603 r = pDeleteStmt->BindInt(0, checkId);
4604 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4606 db.BeginTransaction();
4608 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
4610 db.CommitTransaction();
4617 const Tizen::Base::String
4618 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
4620 if (originUri == L"" || currentUri == L"")
4625 result r = E_SUCCESS;
4628 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4629 String originReplace(originUri);
4630 String table(CUSTOM_PROTOCOL_TABLE_NAME);
4634 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4635 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4637 r = currentUri.SubString(0, found + 1, baseUri);
4638 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4640 r = db.Construct(handlerPath, "r+", null);
4641 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4643 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
4644 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
4648 while (pEnum->MoveNext() == E_SUCCESS)
4653 String originScheme;
4655 r = pEnum->GetStringAt(0, protocol);
4656 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4658 r = pEnum->GetStringAt(1, queryUrl);
4659 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4661 r = pEnum->GetIntAt(2, allow);
4662 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4669 String protocolScheme(protocol + L":");
4671 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
4672 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4674 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
4676 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
4678 r = originReplace.Replace(originScheme, "");
4679 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4681 queryUrl.Replace("%s", originReplace, 0);
4682 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4694 const Tizen::Base::String
4695 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
4697 if (originUri == L"" || currentUri == L"" || mime == L"")
4702 result r = E_SUCCESS;
4705 String originUrlStr = originUri;
4706 const String replaceStr = L"%s";
4708 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4709 String table(CUSTOM_CONTENT_TABLE_NAME);
4713 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4714 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4716 r = currentUri.SubString(0, found + 1, baseUri);
4717 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4719 r = db.Construct(handlerPath, "r+", null);
4720 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4722 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
4726 r = pEnum->MoveNext();
4727 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4728 r = pEnum->GetIntAt(0, allow);
4729 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4730 r = pEnum->GetStringAt(1, contentUrl);
4731 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4739 if (contentUrl != L"")
4741 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
4742 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4753 }}} // Tizen::Web::Controls