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_PageNavigationListImpl.h"
95 #include "FWebCtrl_PromptPopup.h"
96 #include "FWebCtrl_SelectBox.h"
97 #include "FWebCtrl_Utility.h"
98 #include "FWebCtrl_Web.h"
99 #include "FWebCtrl_WebDataHandler.h"
100 #include "FWebCtrl_WebEvent.h"
101 #include "FWebCtrl_WebEventArg.h"
102 #include "FWebCtrl_WebImpl.h"
103 #include "FWebCtrl_WebPresenter.h"
104 #include "FWebCtrl_WebSettingImpl.h"
107 using namespace Tizen::App;
108 using namespace Tizen::Base;
109 using namespace Tizen::Base::Collection;
110 using namespace Tizen::Base::Runtime;
111 using namespace Tizen::Base::Utility;
112 using namespace Tizen::Content;
113 using namespace Tizen::Graphics;
114 using namespace Tizen::Io;
115 using namespace Tizen::Media;
116 using namespace Tizen::Net::Http;
117 using namespace Tizen::Ui;
118 using namespace Tizen::Ui::Animations;
119 using namespace Tizen::Ui::Controls;
120 using namespace Tizen::Web::Json;
123 namespace Tizen { namespace Web { namespace Controls
127 static const char WEB_CTRL[] = "webcontrol";
128 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
131 static const float MIN_ZOOM_LEVEL = 0.3;
132 static const float MAX_ZOOM_LEVEL = 2;
135 static const int REDIRECTION_HEADER_GROUP = 300;
138 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
141 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
142 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
146 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
148 result r = E_SUCCESS;
150 String key(reinterpret_cast< const char* >(pKey));
151 String value(reinterpret_cast< char* >(pValue));
153 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
155 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
156 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
163 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
165 result r = E_SUCCESS;
167 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
168 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
169 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
171 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
173 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
174 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
176 pAttrValue.release();
183 FreeCharArray(void* pData)
185 delete[] reinterpret_cast<char*>(pData);
190 ConvertErrorCode(int error)
192 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
196 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
198 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
200 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
202 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
204 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
206 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
208 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
210 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
212 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
214 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
216 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
218 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
220 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
222 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
223 errorCode = WEB_NO_CONNECTION;
226 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
228 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
229 errorCode = WEB_BAD_URL;
232 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
233 errorCode = WEB_FILE_ACCESS_FAILED;
236 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
237 errorCode = WEB_REQUEST_TIMEOUT;
240 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
241 errorCode = WEB_MIME_NOT_SUPPORTED;
244 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
245 errorCode = WEB_OUT_OF_MEMORY;
248 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
249 errorCode = WEB_REQUEST_MAX_EXCEEDED;
252 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
254 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
256 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
258 case EWK_ERROR_NETWORK_STATUS_OK:
260 case EWK_ERROR_NETWORK_STATUS_CREATED:
262 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
264 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
266 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
268 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
270 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
272 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
274 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
276 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
278 case EWK_ERROR_NETWORK_STATUS_FOUND:
280 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
282 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
284 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
286 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
288 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
289 errorCode = WEB_HTTP_RESPONSE;
292 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
293 errorCode = WEB_INVALID_CERTIFICATE;
297 errorCode = WEB_ERROR_UNKNOWN;
306 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
308 result r = E_SUCCESS;
310 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
311 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
312 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
313 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
315 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
316 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
317 pErrorCode.release();
319 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
320 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
321 pErrorDescription.release();
323 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
324 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
332 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
334 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
336 result r = E_SUCCESS;
338 String msg(pMessage);
340 MessageBox messageBox;
341 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OK);
342 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
345 r = messageBox.ShowAndWait(modalResult);
346 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
348 ewk_view_javascript_alert_reply(pView);
355 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
357 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
359 result r = E_SUCCESS;
361 String msg(pMessage);
363 MessageBox messageBox;
364 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
365 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
368 r = messageBox.ShowAndWait(modalResult);
369 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
371 if (modalResult == MSGBOX_RESULT_OK)
373 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
377 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
385 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
387 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
389 result r = E_SUCCESS;
391 String msg(pMessage);
392 String defVal(pDefaultValue);
394 int modalResult = -1;
395 Eina_Bool returnValue = EINA_TRUE;
396 _PromptPopup pPromptPopup;
398 r = pPromptPopup.Construct(msg, defVal);
399 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, returnValue = EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
401 r = pPromptPopup.ShowAndWait(modalResult);
402 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, returnValue = EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
404 if (modalResult == ID_BUTTON_PROMPT_OK)
406 std::unique_ptr<char[]> pResult(_StringConverter::CopyToCharArrayN(pPromptPopup.GetPromptText()));
407 SysTryCatch(NID_WEB_CTRL, pResult.get(), returnValue = EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
409 ewk_view_javascript_prompt_reply(pView, pResult.get());
414 ewk_view_javascript_prompt_reply(pView, null);
420 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
422 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
423 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
424 SysAssertf(pImpl && pPolicy, "Failed to request");
426 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
428 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
430 if (pImpl->IsCertificateRequested())
432 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
436 result r = E_SUCCESS;
438 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
439 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
441 pImpl->SetCertificateRequested(true);
444 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
446 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
448 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
449 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
458 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
460 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
461 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
462 SysAssertf(pImpl && pChallenge, "Failed to request");
464 result r = E_SUCCESS;
466 r = pImpl->HttpAuthenticationRequested(pChallenge);
467 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
471 ewk_auth_challenge_credential_cancel(pChallenge);
472 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
477 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
479 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
480 SysAssertf(pImpl , "Failed to request");
482 if (pImpl->GetLoadingListener())
484 result r = E_SUCCESS;
486 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
487 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
489 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
490 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
497 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
499 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
500 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
501 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
503 if (pImpl->GetSetting().IsGeolocationEnabled())
505 result r = E_SUCCESS;
507 std::unique_ptr<DbEnumerator> pEnum;
509 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
510 String table(GEOLOCATION_TABLE_NAME);
513 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
514 String origin = _Utility::CreateOrigin(pSecurityOrigin);
516 r = db.Construct(geolocationPath, "r", null);
517 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
519 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
522 r = pEnum->MoveNext();
523 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
526 r = pEnum->GetIntAt(0, permission);
527 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
529 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
531 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
535 ewk_geolocation_permission_request_suspend(pPermissionRequest);
537 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
538 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
545 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
550 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
552 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
553 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
554 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
556 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
557 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
561 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
566 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
568 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
569 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
570 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
572 SysLog(NID_WEB_CTRL, "The permission popup has not Implemented yet. allow is the default value now.");
574 //ToDo : Show NotificationPermissionPopup
576 Ewk_Context* pContext = ewk_view_context_get(pView);
577 SysAssertf(pContext, "Failed to get webkit instance.");
579 //ewk_notification_permission_request_origin_get(pPermissionRequest);
581 ewk_notification_permission_request_set(pPermissionRequest, EINA_TRUE);
586 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
588 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
589 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
590 SysAssertf(pImpl && pNotification, "Failed to request");
592 Ewk_Context* pContext = ewk_view_context_get(pView);
593 SysAssertf(pContext, "Failed to get webkit instance.");
595 //ToDo : Show Notification
596 //Perform ewk_notification_clicked
597 //ewk_notification_security_origin_get(pNotification)
598 SysLog(NID_WEB_CTRL, "The current value of title is %s", ewk_notification_title_get(pNotification));
599 SysLog(NID_WEB_CTRL, "The current value of body is %s", ewk_notification_body_get(pNotification));
600 SysLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
602 uint64_t notificationId = ewk_notification_id_get(pNotification);
603 ewk_notification_showed(pContext, notificationId);
608 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
610 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
611 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
612 SysAssertf(pImpl && pNotificationID, "Failed to request");
614 //ToDo : Where is ewk API for cancel operation?
619 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
621 result r = E_SUCCESS;
622 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
623 SysAssertf(pImpl, "Failed to request");
625 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
626 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
631 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
633 int checkHandler = 0;
634 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
635 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
636 SysAssertf(pImpl && pHandlerData, "Failed to request");
638 checkHandler = pImpl->SearchHandler(pHandlerData, false);
639 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
640 switch (checkHandler)
645 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
648 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
651 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
659 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
661 result r = E_SUCCESS;
662 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
663 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
664 SysAssertf(pImpl && pHandlerData, "Failed to request");
666 r = pImpl->UnregistrationHandler(pHandlerData, false);
667 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
672 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
674 result r = E_SUCCESS;
675 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
676 SysAssertf(pImpl, "Failed to request");
678 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
679 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
684 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
686 int checkHandler = 0;
687 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
688 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
689 SysAssertf(pImpl && pHandlerData, "Failed to request");
691 checkHandler = pImpl->SearchHandler(pHandlerData, true);
692 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
694 switch (checkHandler)
699 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
702 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
705 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
713 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
715 result r = E_SUCCESS;
716 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
717 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
718 SysAssertf(pImpl && pHandlerData, "Failed to request");
720 r = pImpl->UnregistrationHandler(pHandlerData, true);
721 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
726 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
728 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
729 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
730 SysAssertf(pImpl && pPolicy, "Failed to request");
732 String url(ewk_policy_decision_url_get(pPolicy));
733 SysLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
735 if (url == L"about:blank")
737 ewk_policy_decision_use(pPolicy);
741 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
742 && !pImpl->IsRedirectRequested())
744 pImpl->SetCertificateRequested(false);
746 if (pImpl->GetTextSearchListener())
748 pImpl->DisableAsyncSearch();
751 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
752 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
754 switch (ewkNavigationType)
756 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
757 navigationType = WEB_NAVIGATION_LINK_CLICKED;
759 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
760 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
762 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
763 navigationType = WEB_NAVIGATION_BACKFORWARD;
765 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
766 navigationType = WEB_NAVIGATION_RELOAD;
768 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
769 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
771 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
772 navigationType = WEB_NAVIGATION_OTHER;
778 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
780 ewk_policy_decision_ignore(pPolicy);
786 String currentUrl = pImpl->GetUrl();
788 String redirectUrl = pImpl->GetProtocolFromUri(url, currentUrl);
789 if (redirectUrl != null)
791 pImpl->LoadUrl(redirectUrl);
792 ewk_policy_decision_ignore(pPolicy);
799 String uriScheme(uri.GetScheme());
800 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
802 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
804 ewk_policy_decision_ignore(pPolicy);
806 if (uriScheme == L"")
811 result r = E_SUCCESS;
813 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
815 if (uriScheme == L"rtsp")
817 eventType = WEB_EVENT_REQUEST_RTSP;
819 else if (uriScheme == L"mailto")
821 eventType = WEB_EVENT_REQUEST_EMAIL;
823 else if (uriScheme == L"tel")
825 eventType = WEB_EVENT_REQUEST_TEL;
827 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
829 eventType = WEB_EVENT_REQUEST_SMS;
831 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
833 eventType = WEB_EVENT_REQUEST_MMS;
836 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
837 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
839 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
840 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
846 ewk_policy_decision_use(pPolicy);
851 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
853 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
854 SysAssertf(pImpl, "Failed to request");
856 if (pImpl->GetLoadingListener())
858 result r = E_SUCCESS;
860 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
861 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
863 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
864 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
871 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
873 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
874 char* pTitle = reinterpret_cast< char* >(pEventInfo);
875 SysAssertf(pImpl, "Failed to request");
877 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
879 if (pImpl->GetLoadingListener())
881 result r = E_SUCCESS;
883 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
884 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
885 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
887 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
888 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
889 pPageTitle.release();
891 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
892 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
899 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
901 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
902 double* pProgress = reinterpret_cast< double* >(pEventInfo);
903 SysAssertf(pImpl, "Failed to request");
905 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
907 if (pImpl->GetLoadingListener())
909 result r = E_SUCCESS;
911 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
912 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
913 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
915 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
916 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
917 pProgressPercentage.release();
919 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
920 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
927 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
929 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
930 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
931 SysAssertf(pImpl && pPolicy, "Failed to request");
933 result r = E_SUCCESS;
935 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
936 int code = ewk_policy_decision_response_status_code_get(pPolicy);
937 String mime(ewk_policy_decision_response_mime_get(pPolicy));
938 SysLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
940 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
942 String url(ewk_policy_decision_url_get(pPolicy));
945 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
947 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
949 DecisionPolicy policy;
950 HttpHeader httpHeader;
952 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
954 pImpl->SetRedirectRequested(true);
958 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
959 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
961 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
962 pImpl->SetPolicyDecision(policy);
965 switch (pImpl->GetPolicyDecision())
967 case WEB_DECISION_CONTINUE:
970 String currentUrl = pImpl->GetUrl();
971 String redirectUrl = pImpl->GetRedirectUri(url, currentUrl, mime);
972 if (redirectUrl != L"")
974 pImpl->LoadUrl(redirectUrl);
975 ewk_policy_decision_ignore(pPolicy);
978 if (pImpl->IsMimeSupported(mime) || mime == L"")
985 SysLog(NID_WEB_CTRL, "Launch native app to handle the mime");
987 ewk_policy_decision_ignore(pPolicy);
989 AppControl* pAppControl = null;
990 _SelectBox selectBox;
992 int selectedIndex = 0;
994 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
998 appCount = pList->GetCount();
1001 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
1002 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1004 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1005 for (int i = 0; i < appCount; i++)
1007 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
1008 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1010 String text = pAppControl->GetAppName();
1011 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
1013 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1015 r = selectBox.ShowAndWait(selectedIndex);
1016 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1018 if (selectedIndex == 0) //download
1020 RequestId reqId = 0;
1021 DownloadRequest request(pUrl);
1023 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1024 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1026 r = pManagerImpl->Start(request, reqId);
1027 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1029 else if (selectedIndex != -1) // -1 for cancel
1031 String path("path");
1032 String pathVal(pUrl);
1035 r = dataList.Construct();
1036 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1038 r = dataList.Add(path, pathVal);
1039 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1041 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
1042 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1044 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
1045 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1047 r = pAcImpl->Start(null, null, &dataList, null);
1048 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1055 case WEB_DECISION_DOWNLOAD:
1057 ewk_policy_decision_ignore(pPolicy);
1059 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1060 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1062 Ewk_Context* pContext = ewk_view_context_get(pView);
1063 SysAssertf(pContext, "Failed to get webkit instance.");
1065 pDownloadHandler->StartDownload(pUrl);
1069 case WEB_DECISION_IGNORE:
1071 ewk_policy_decision_ignore(pPolicy);
1081 ewk_policy_decision_use(pPolicy);
1086 ewk_policy_decision_ignore(pPolicy);
1091 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1093 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1094 SysAssertf(pImpl, "Failed to request");
1096 if (pImpl->IsRedirectRequested())
1098 pImpl->SetRedirectRequested(false);
1101 if (pImpl->IsLoadingErrorOccurred())
1103 pImpl->SetLoadingErrorOccurred(false);
1104 evas_object_smart_callback_call(pView, "load,finished", NULL);
1110 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1112 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1113 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1114 SysAssertf(pImpl && pErrorData, "Failed to request");
1116 int code = ewk_error_code_get(pErrorData);
1117 const char* pDescription = ewk_error_description_get(pErrorData);
1119 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1121 pImpl->SetLoadingErrorOccurred(true);
1124 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1126 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1129 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1130 evas_object_smart_callback_call(pView, "load,stop", NULL);
1134 if (pImpl->GetLoadingListener())
1136 result r = E_SUCCESS;
1138 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1139 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1147 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1149 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1150 SysAssertf(pImpl, "Failed to request");
1152 if (pImpl->GetLoadingListener())
1154 result r = E_SUCCESS;
1156 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1157 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1159 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1160 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1161 pEventArg.release();
1168 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1170 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1171 SysAssertf(pImpl, "Failed to request");
1173 if (pImpl->GetLoadingListener())
1175 result r = E_SUCCESS;
1177 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1178 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1180 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1181 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1182 pEventArg.release();
1189 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1191 evas_object_focus_set(pView, EINA_FALSE);
1196 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1198 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1199 SysAssertf(pImpl, "Failed to request");
1201 if (pImpl->GetLoadingListener())
1203 result r = E_SUCCESS;
1205 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1206 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1208 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1209 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1210 pEventArg.release();
1217 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1219 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1220 SysAssertf(pUrl && pImpl != null, "Failed to request");
1222 SysLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1227 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1229 result r = E_SUCCESS;
1231 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1232 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1234 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1235 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1236 pEventArg.release();
1243 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1245 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1246 SysAssertf(pImpl, "Failed to request");
1248 if (pImpl->GetUiEventListener())
1250 result r = E_SUCCESS;
1252 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1253 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1255 if (pImpl->GetUiEventListenerF())
1257 result r = E_SUCCESS;
1259 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1260 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1266 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1268 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1269 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1270 SysAssertf(pParentImpl && pChildView, "Failed to request");
1272 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1273 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1274 if (pUserUiListener)
1276 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1279 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1280 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1282 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1283 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1286 if (pUserUiListenerF)
1288 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1291 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1292 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1294 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1295 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1302 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1304 result r = E_SUCCESS;
1306 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1307 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1309 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1310 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1311 pEventArg.release();
1318 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1320 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1321 SysAssertf(pChildImpl, "Failed to request");
1323 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1324 if (pParentImpl == null)
1329 if (pParentImpl->GetUiEventListener())
1331 result r = E_SUCCESS;
1333 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1334 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1336 if (pParentImpl->GetUiEventListenerF())
1338 result r = E_SUCCESS;
1340 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1341 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1347 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1349 result r = E_SUCCESS;
1351 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1352 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1353 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1355 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1356 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1357 pPreventTrigger.release();
1359 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1360 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1361 pEventArg.release();
1368 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1370 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1371 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1372 SysAssertf(pImpl && pTrigger, "Failed to request");
1374 if (pImpl->GetUiEventListener())
1376 result r = E_SUCCESS;
1378 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1379 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1381 if (pImpl->GetUiEventListenerF())
1383 result r = E_SUCCESS;
1385 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1386 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1392 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1394 result r = E_SUCCESS;
1396 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1397 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1398 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1400 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1402 if ((endPoint->x != 0) && (endPoint->y != 0))
1404 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1405 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1407 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1408 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1409 startPoint.release();
1411 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1412 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1415 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1416 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1417 pEventArg.release();
1425 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1427 result r = E_SUCCESS;
1429 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1430 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1432 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1434 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1436 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1438 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1439 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1441 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1442 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1443 startPoint.release();
1445 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1446 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1449 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1450 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1451 pEventArg.release();
1459 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1461 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1462 Ewk_Text_Style* pStyle = reinterpret_cast< Ewk_Text_Style* >(pEventInfo);
1463 SysAssertf(pImpl && pStyle, "Failed to request");
1465 if (pImpl->GetUiEventListener())
1467 result r = E_SUCCESS;
1469 r = FireWebPageBlockSelectedEvent(pImpl);
1470 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1472 if (pImpl->GetUiEventListenerF())
1474 result r = E_SUCCESS;
1476 r = FireWebPageBlockSelectedEventF(pImpl);
1477 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1483 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1485 Eina_Bool ret = EINA_FALSE;
1486 Eina_List* pSelectedFileNames = null;
1487 String isMultipleSelection(L"single");
1491 isMultipleSelection.Append(L"multiple");
1494 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1495 SysTryCatch(NID_WEB_CTRL, pMediaListener.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1498 int itemCount = eina_list_count(pAcceptTypes);
1499 String fileType = L"all";
1503 String item((char*)eina_list_nth(pAcceptTypes, 0));
1504 if (item.StartsWith("image/",0))
1506 fileType = L"image";
1508 else if (item.StartsWith("audio/",0))
1510 fileType = L"audio";
1512 else if (item.StartsWith("video/",0))
1514 fileType = L"video";
1519 result r = dataList.Construct();
1520 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1522 String mode(L"selectionType");
1523 r = dataList.Add(mode, isMultipleSelection);
1524 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1526 String type(L"type");
1527 r = dataList.Add(type, fileType);
1528 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1530 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1531 SysTryCatch(NID_WEB_CTRL, pMediaAppControl.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1533 _AppControlImpl* pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl);
1534 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1535 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1539 if (pMediaListener->IsSelectionCompleted())
1541 const ArrayList* pSelectedFiles = pMediaListener->GetSelectedFiles();
1542 SysTryCatch(NID_WEB_CTRL, pSelectedFiles, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1544 int fileCount = pSelectedFiles->GetCount();
1546 for (int i = 0; i < fileCount; i++)
1548 String* pFile = (String*)pSelectedFiles->GetAt(i);
1549 SysTryCatch(NID_WEB_CTRL, pFile, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1551 std::unique_ptr<ByteBuffer> pByteBuf(StringUtil::StringToUtf8N(*pFile));
1552 SysTryCatch(NID_WEB_CTRL, pByteBuf.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1554 pSelectedFileNames = eina_list_append(pSelectedFileNames, strdup((const char*)pByteBuf->GetPointer()));
1561 ecore_main_loop_iterate();
1564 ewk_view_open_panel_reply(pView, pSelectedFileNames, ret);
1569 ewk_view_open_panel_reply(pView, null, ret);
1570 eina_list_free(pSelectedFileNames);
1576 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1578 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1579 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1580 SysAssertf(pImpl && pJsonText, "Failed to request");
1582 result r = E_SUCCESS;
1584 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1586 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1587 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1589 r = pEventArg->Construct(pJsonText);
1590 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1592 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1593 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1594 pEventArg.release();
1599 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1601 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1602 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1603 SysAssertf(pImpl && pEinaRect, "Failed to request");
1605 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1607 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1608 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1610 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1612 if (rect.height == 0)
1617 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1618 SysAssertf(pFormCore != null, "Failed to get FormCore");
1620 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1622 pImpl->SetFooterVisibleState(true);
1623 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1626 if (pImpl->GetWebKeypadEventListener())
1628 if (pImpl->IsKeypadVisible() == true)
1630 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1632 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1637 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1638 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1641 pImpl->SetKeypadVisibleState(true);
1642 pImpl->SetPreviousKeypadBounds(rect);
1646 result r = pImpl->SetFullScreenKeypad();
1647 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1653 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1655 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1656 SysAssertf(pImpl, "Failed to request");
1658 if (pImpl->GetWebKeypadEventListener())
1660 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1666 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1668 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1669 SysAssertf(pImpl, "Failed to request");
1671 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1672 SysAssertf(pFormCore != null, "Failed to get FormCore");
1674 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1676 pImpl->SetFooterVisibleState(false);
1677 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1680 pFormCore->DeflateClientRectHeight(0);
1682 if (pImpl->GetWebKeypadEventListener())
1684 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1687 pImpl->SetKeypadVisibleState(false);
1692 OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info)
1694 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1695 SysAssertf(pImpl, "Failed to request");
1697 if (pImpl->IsKeypadOpened() == true)
1699 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1700 SysAssertf(pWebCore, "Failed to get Web core object");
1702 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1704 pImpl->SetKeypadOpened(false);
1710 OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo)
1712 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1713 SysAssertf(pImpl, "Failed to request");
1715 if (pImpl->IsKeypadOpened() == true)
1717 pImpl->SetKeypadOpened(false);
1723 OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha)
1725 SysAssertf(pSmartData, "invalid smartdata");
1726 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1727 SysAssertf(pWebImpl, "Failed to get Impl");
1729 result r = E_SUCCESS;
1731 if (pWebImpl->GetColorpicker())
1738 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1739 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1741 byte r1, g1, b1, a1;
1742 color.GetColorComponents(r1, g1, b1, a1);
1743 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1750 OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData)
1752 SysAssertf(pSmartData, "invalid smartdata");
1754 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1755 SysAssertf(pWebImpl, "Failed to get Impl");
1757 return pWebImpl->HideColorPicker();
1762 OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1764 SysAssertf(pSmartData, "Failed to request");
1765 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1766 SysAssertf(pWebImpl, "Failed to get Impl");
1768 result r = E_SUCCESS;
1770 if (pWebImpl->GetDatepicker())
1772 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1779 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1780 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1782 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1783 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1785 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1792 OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1794 SysAssertf(pSmartData, "Failed to request");
1796 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1797 SysAssertf(pWebImpl, "Failed to get Impl");
1799 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1800 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1807 OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData)
1809 SysAssertf(pSmartData, "invalid smartdata");
1811 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1812 SysAssertf(pWebImpl, "Failed to get Impl");
1814 result r = pWebImpl->ClearSelectBoxPopup();
1815 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1822 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1824 SysAssertf(pSmartData, "invalid smartdata");
1826 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1827 SysAssertf(pWebImpl, "Failed to get Impl");
1829 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1830 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1837 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1839 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1840 SysAssertf(pPresenter && !pError, "Failed to request");
1842 bool ret = EINA_TRUE;
1846 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1848 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1852 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1861 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1863 pPresenter->EndAsyncProcess(ret);
1868 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1870 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1871 SysAssertf(pPresenter, "Failed to request");
1873 String result(pResult);
1874 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1876 pPresenter->EndAsyncProcess(result);
1881 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
1883 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1884 SysAssertf(pImpl, "Failed to request");
1886 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
1887 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
1889 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
1893 pWebPresenter->EndAsyncProcess(*pTotalCount);
1897 if (pImpl->GetTextSearchListener())
1899 result r = E_SUCCESS;
1903 if (*pTotalCount > 0)
1905 ordinal = pImpl->GetAsyncSearchOrdinal();
1906 pImpl->SetAsyncSearchResult(*pTotalCount);
1909 if (pImpl->GetPendingAsyncSearchCount() > 0)
1914 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
1915 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
1916 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
1917 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1919 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
1920 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1923 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
1924 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1927 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1928 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1929 pEventArg.release();
1935 class _JsBridgeHashCodeProvider
1936 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
1939 _JsBridgeHashCodeProvider(){}
1940 virtual ~_JsBridgeHashCodeProvider(void) {}
1943 int GetHashCode(const Tizen::Base::String& obj) const
1945 return obj.GetHashCode();
1951 //Comparer implementation
1952 class _JsBridgeComparer
1953 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
1956 _JsBridgeComparer(){}
1957 virtual ~_JsBridgeComparer(void) {}
1960 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
1977 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
1978 : _ContainerImpl(pWeb, pCore)
1979 , __isFooterVisible(false)
1980 , __isKeypadVisible(false)
1981 , __isKeypadOpened(false)
1982 , __isLoadingErrorOccurred(false)
1983 , __isRedirectRequested(false)
1984 , __isCertificateRequested(false)
1985 , __isCertificateConfirmed(false)
1986 , __keypadBounds(0, 0, 0, 0)
1988 , __pUserLoadingListener(null)
1989 , __pUserUiListener(null)
1990 , __pUserUiListenerF(null)
1991 , __pUserKeypadEventListener(null)
1992 , __pTextSearchListener(null)
1994 , __pJsBridgeList(null)
1995 , __pJsProvider(null)
1996 , __pJsComparer(null)
1997 , __pWebDownloadHandler(null)
1999 , __pAuthChallenge(null)
2000 , __pAuthPopup(null)
2001 , __pUserConfirmPopup(null)
2002 , __pCertConfirmPopup(null)
2003 , __pSelectBox(null)
2004 , __pDatePicker(null)
2005 , __pColorPicker(null)
2006 , __policy(WEB_DECISION_CONTINUE)
2008 __textSearch.__searchAll = false;
2009 __textSearch.__searchForward = true;
2010 __textSearch.__caseSensitive = false;
2011 __textSearch.__pending = 0;
2012 __textSearch.__currentIndex = 1;
2013 __textSearch.__totalCount = -1;
2014 __textSearch.__text = L"";
2018 _WebImpl::~_WebImpl()
2020 RemoveEventListenerCallback();
2024 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2026 result r = E_SUCCESS;
2028 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2029 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2031 _Web* pCore = _Web::CreateWebN();
2032 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2034 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2036 r = CheckConstruction(pCore, pImpl);
2037 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2039 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2040 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2042 r = pImpl->Construct();
2043 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2055 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2057 result r = E_SUCCESS;
2059 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2060 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2062 _Web* pCore = _Web::CreateWebN();
2063 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2065 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2067 r = CheckConstruction(pCore, pImpl);
2068 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2070 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2071 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2073 r = pImpl->Construct();
2074 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2086 _WebImpl::Construct(void)
2088 result r = E_SUCCESS;
2090 r = __mutex.Create();
2091 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2093 r = __textSearch.__searchQueue.Construct();
2094 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2096 r = InitJsBridgeList();
2097 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2100 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2102 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2103 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2110 _WebImpl::InitializeSetting(void)
2112 result r = E_SUCCESS;
2114 r = SetSetting(*__pWebCore->GetSetting());
2115 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2117 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2119 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2120 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2121 SetZoomLevel(pWebSettingImpl->GetZoomLevel());
2123 SetEventListenerCallback();
2125 _Form* pFormCore = GetParentFormCore(dynamic_cast< _Control* >(&this->GetCore()));
2126 SysAssertf(pFormCore != null, "Failed to get FormCore");
2133 _WebImpl::IsLayoutable(void) const
2140 _WebImpl::InitWebEvent(void)
2142 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2143 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2145 return __pWebEvent->Construct(*this);
2150 _WebImpl::GetWebEvent(void) const
2152 return __pWebEvent.get();
2157 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2159 Eina_Hash* pHttpHeader = null;
2161 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2162 if (pFieldNameList.get())
2164 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2165 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2167 int count = pFieldNameList->GetCount();
2169 for (int i = 0; i < count; i++)
2171 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2172 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2174 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2175 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2177 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2178 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2180 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2182 Eina_Bool ret = false;
2184 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2185 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2187 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2188 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2190 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2191 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2198 eina_hash_free(pHttpHeader);
2205 _WebImpl::LoadUrl(const String& url) const
2207 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2208 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2210 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2217 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2219 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2220 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2222 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2224 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2226 eina_hash_free(pHttpHeader);
2233 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2235 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2236 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2238 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2240 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2242 eina_hash_free(pHttpHeader);
2249 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2251 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2253 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2254 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2255 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2256 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2258 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2265 _WebImpl::Pause(void)
2267 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2272 _WebImpl::Resume(void)
2274 ewk_view_resume(__pWebCore->GetWebNativeNode());
2279 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2281 __pSelectBox.reset();
2283 int itemCount = eina_list_count(pItems);
2284 SysTryReturnResult(NID_WEB_CTRL, itemCount > 0, E_SYSTEM, "ItemCount is invalid.");
2286 result r = E_SUCCESS;
2288 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2289 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2291 r = pSelectBox->Construct(isMultiSelect, title, itemCount, pWebView);
2292 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2294 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2295 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2297 __pSelectBox = std::move(pSelectBox);
2299 return __pSelectBox->ShowPopup();
2304 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2306 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2308 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2313 _WebImpl::ClearSelectBoxPopup(void)
2315 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2317 __pSelectBox.reset();
2324 _WebImpl::GetDatepicker(void)
2326 _InputPickerPopup* pInputPicker =null;
2329 pInputPicker = __pDatePicker.get();
2331 return pInputPicker;
2336 _WebImpl::GetColorpicker(void)
2338 _InputPickerPopup* pInputPicker =null;
2341 pInputPicker = __pColorPicker.get();
2343 return pInputPicker;
2348 _WebImpl::CanGoBack(void) const
2350 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2355 _WebImpl::CanGoForward(void) const
2357 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2362 _WebImpl::GoBack(void) const
2364 ewk_view_back(__pWebCore->GetWebNativeNode());
2369 _WebImpl::GoForward(void) const
2371 ewk_view_forward(__pWebCore->GetWebNativeNode());
2376 _WebImpl::GetUrl(void) const
2378 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2383 _WebImpl::GetTitle(void) const
2385 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2390 _WebImpl::StopLoading(void) const
2392 ewk_view_stop(__pWebCore->GetWebNativeNode());
2397 _WebImpl::Reload(void) const
2399 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
2404 _WebImpl::EvaluateJavascriptN(const String& scriptCode) const
2406 if (scriptCode.GetLength())
2408 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2409 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2411 _WebPresenter presenter;
2412 presenter.InitAsyncProcess();
2414 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, &presenter);
2416 Tizen::Base::String* pResult = new (std::nothrow) Tizen::Base::String(L"");
2417 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2418 presenter.WaitAsyncProcess(*pResult);
2428 _WebImpl::SetZoomLevel(float level)
2430 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);
2432 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2439 _WebImpl::GetZoomLevel(void) const
2441 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2445 const PageNavigationList*
2446 _WebImpl::GetBackForwardListN(void) const
2448 result r = E_SUCCESS;
2450 _PageNavigationListImpl* pNavigationListImpl = null;
2451 _HistoryItemImpl* pHistoryItemImpl = null;
2453 std::unique_ptr<PageNavigationList> pNavigationList;
2454 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2457 int forwardCount = 0;
2462 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2463 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2465 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2466 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2468 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2469 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2471 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2472 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2474 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2475 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2477 r = pHistoryList->Construct();
2478 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2480 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2481 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2482 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2484 for (int i = -backCount; i < forwardCount + 1; i++)
2486 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2487 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2489 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2490 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2492 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2493 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2495 url = ewk_history_item_uri_get(pEwkItem);
2496 title = ewk_history_item_title_get(pEwkItem);
2497 SysLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2499 pHistoryItemImpl->SetHistoryItem(url, title);
2501 r = pHistoryList->Add(*pHistoryItem.get());
2502 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2503 pHistoryItem.release();
2506 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2508 ewk_history_free(pEwkHistoryList);
2510 return pNavigationList.release();
2513 ewk_history_free(pEwkHistoryList);
2520 _WebImpl::SearchText(const String& text, bool searchForward)
2522 result r = E_SUCCESS;
2524 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2528 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2531 _WebPresenter presenter;
2532 presenter.InitAsyncProcess();
2534 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2535 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2538 presenter.WaitAsyncProcess(result);
2540 return static_cast < bool >(result);
2545 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2547 result r = E_SUCCESS;
2549 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2553 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2556 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2557 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2564 _WebImpl::SearchNextAsync(bool searchForward)
2566 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2567 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2568 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2570 result r = E_SUCCESS;
2572 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2574 if (__textSearch.__caseSensitive)
2576 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2581 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2584 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2585 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2592 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2594 MutexGuard lock(__mutex);
2596 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2597 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2602 if (__textSearch.__searchAll)
2604 DisableAsyncSearch();
2606 __textSearch.__searchQueue.Enqueue(this);
2607 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2609 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2610 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2614 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2616 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2620 case SEARCH_ALL_ASYNC:
2621 __textSearch.__searchAll = true;
2622 __textSearch.__text = text;
2623 __textSearch.__searchForward = true;
2624 __textSearch.__caseSensitive = caseSensitive;
2625 __textSearch.__totalCount = -1;
2626 __textSearch.__currentIndex = 1;
2628 __textSearch.__searchQueue.Enqueue(this);
2629 __textSearch.__searchQueue.Enqueue(this);
2631 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2632 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2635 case SEARCH_NEXT_ASYNC:
2636 __textSearch.__searchForward = searchForward;
2638 CalculateAsyncSearchOrdinal();
2640 __textSearch.__searchQueue.Enqueue(this);
2642 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2654 _WebImpl::SetAsyncSearchResult(int totalCount)
2656 __textSearch.__totalCount = totalCount;
2661 _WebImpl::GetSearchPresenter(void)
2663 MutexGuard lock(__mutex);
2665 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2670 _WebImpl::GetPendingAsyncSearchCount(void) const
2672 return __textSearch.__searchQueue.GetCount();
2677 _WebImpl::CalculateAsyncSearchOrdinal(void)
2679 if (__textSearch.__searchForward)
2681 __textSearch.__currentIndex++;
2685 __textSearch.__currentIndex--;
2691 _WebImpl::GetAsyncSearchOrdinal(void) const
2693 return __textSearch.__currentIndex;
2698 _WebImpl::DisableAsyncSearch(void)
2700 __textSearch.__searchAll = false;
2705 _WebImpl::SetSetting(const WebSetting& setting)
2707 if (__pWebCore->GetWebNativeNode())
2709 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2710 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2711 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2713 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2714 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2716 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2718 switch (setting.GetCacheControl())
2720 case WEB_CACHE_VALIDATED:
2721 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2724 case WEB_CACHE_IGNORE:
2725 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2732 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2734 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2738 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2741 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2743 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2745 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2747 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2748 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2750 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2752 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2754 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2756 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2758 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2761 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2763 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2764 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2765 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2766 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2767 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2768 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2769 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2770 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2771 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2772 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2773 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2774 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2775 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2782 _WebImpl::GetSetting(void) const
2784 return *__pWebCore->GetSetting();
2788 const HitElementResult*
2789 _WebImpl::GetElementByPointN(const Point& point) const
2791 result r = E_SUCCESS;
2793 _HitElementResultImpl* pHitElementResultImpl = null;
2795 std::unique_ptr<HitElementResult> pHitElementResult;
2796 std::unique_ptr<Bitmap> pImage;
2797 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2799 Point absPoint(__pWebCore->GetAbsoluteCoordinate(point));
2801 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2802 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2804 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2805 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2806 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2807 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2808 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2810 SysLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2812 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2813 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2815 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2816 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2818 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
2824 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
2825 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
2826 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
2827 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
2829 r = buf.Construct(imageLength);
2830 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2832 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
2833 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2837 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
2838 // webkit support types such as ico and vp8 additionally
2839 if (strcmp(pExtension, "gif") == 0)
2841 format = IMG_FORMAT_GIF;
2843 else if (strcmp(pExtension, "jpg") == 0)
2845 format = IMG_FORMAT_JPG;
2847 else if (strcmp(pExtension, "png") == 0)
2849 format = IMG_FORMAT_PNG;
2851 else if (strcmp(pExtension, "bmp") == 0)
2853 format = IMG_FORMAT_BMP;
2857 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
2861 r = image.Construct();
2862 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2864 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
2865 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2870 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
2871 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2873 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
2874 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2876 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
2877 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2880 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
2882 ewk_hit_test_free(pEwkHitTest);
2884 return pHitElementResult.release();
2887 ewk_hit_test_free(pEwkHitTest);
2893 const HitElementResult*
2894 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2896 const Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
2898 std::unique_ptr<const HitElementResult> pHitElementResult(GetElementByPointN(integerPoint));
2899 SysTryReturn(NID_WEB_CTRL, pHitElementResult.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2901 return pHitElementResult.release();
2906 _WebImpl::IsLoading(void) const
2908 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
2910 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
2922 _WebImpl::GetTextFromBlock(void) const
2924 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
2929 _WebImpl::IsPrivateBrowsingEnabled(void) const
2931 if (__pWebCore->GetWebNativeNode() == null)
2933 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
2936 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2937 SysAssertf(pSettings, "Failed to get webkit instance.");
2939 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
2944 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
2946 if (__pWebCore->GetWebNativeNode() == null)
2948 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
2952 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2953 SysAssertf(pSettings, "Failed to get webkit instance.");
2955 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
2960 _WebImpl::ClearHistory(void)
2962 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
2967 _WebImpl::ClearCache(void)
2969 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2970 SysAssertf(pContext, "Failed to get webkit instance.");
2972 ewk_context_cache_clear(pContext);
2977 _WebImpl::ClearCookie(void)
2979 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2980 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2981 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2983 ewk_cookie_manager_cookies_clear(pCookieManager);
2988 _WebImpl::ClearFormData(void)
2990 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2991 SysAssertf(pContext, "Failed to get webkit instance.");
2993 ewk_context_form_candidate_data_clear(pContext);
2998 _WebImpl::ClearLoginFormData(void)
3000 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3001 SysAssertf(pContext, "Failed to get webkit instance.");
3003 ewk_context_form_password_data_clear(pContext);
3008 _WebImpl::IsCookieEnabled(void) const
3010 if (__pWebCore->GetWebNativeNode() == null)
3012 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3015 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3016 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3017 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3019 _WebPresenter presenter;
3020 presenter.InitAsyncProcess();
3022 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3024 bool result = false;
3025 presenter.WaitAsyncProcess(result);
3032 _WebImpl::SetCookieEnabled(bool enable)
3034 if (__pWebCore->GetWebNativeNode() == null)
3036 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3041 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3042 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3043 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3047 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY);
3051 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3052 ewk_cookie_manager_cookies_clear(pCookieManager);
3058 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3060 result r = E_SUCCESS;
3062 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3063 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3066 String fileExtension = File::GetFileExtension(filePath);
3067 int pathLength = filePath.GetLength();
3070 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3072 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3073 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3074 r = filePath.SubString(0, index + 1, dirPath);
3075 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3077 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3078 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3082 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3084 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3088 Evas_Coord contentsWidth;
3089 Evas_Coord contentsHeight;
3091 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3092 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3100 _WebImpl::IsMimeSupported(const String& mime) const
3102 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3103 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3105 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3110 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3112 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3117 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3119 __pUserUiListener = pUiEventListener;
3124 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3126 __pUserUiListenerF = pUiEventListener;
3131 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3133 __pUserKeypadEventListener = pKeypadEventListener;
3138 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3140 if (__pWebDownloadHandler.get() == null)
3142 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3143 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3146 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3147 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3152 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3154 __pTextSearchListener = pTextSearchListener;
3159 _WebImpl::SetScrollEnabled(bool enable)
3161 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3166 _WebImpl::IsScrollEnabled(void) const
3168 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3173 _WebImpl::InitJsBridgeList(void)
3175 result r = E_SUCCESS;
3177 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3178 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3180 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3181 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3183 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3184 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3186 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3187 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3189 __pJsBridgeList = std::move(pJsBridgeList);
3196 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3198 result r = E_SUCCESS;
3200 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3201 String key(pJsBridge->GetName());
3203 r = __pJsBridgeList->Add(key, pJsBridge);
3204 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3211 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3213 result r = E_SUCCESS;
3215 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3216 String key(pJsBridge->GetName());
3218 r = __pJsBridgeList->Remove(key);
3219 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3226 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3228 result r = E_SUCCESS;
3230 IJsonValue* pJsonValue = null;
3231 IJavaScriptBridge* pJsBridge = null;
3233 String key(L"name");
3235 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3236 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));
3238 r = pJsonObject->GetValue(&key, pJsonValue);
3239 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3241 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3242 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3244 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3245 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3252 _WebImpl::GetLoadingListener(void) const
3254 return __pUserLoadingListener;
3258 IWebUiEventListener*
3259 _WebImpl::GetUiEventListener(void) const
3261 return __pUserUiListener;
3265 IWebUiEventListenerF*
3266 _WebImpl::GetUiEventListenerF(void) const
3268 return __pUserUiListenerF;
3272 IWebKeypadEventListener*
3273 _WebImpl::GetWebKeypadEventListener(void) const
3275 return __pUserKeypadEventListener;
3279 ITextSearchListener*
3280 _WebImpl::GetTextSearchListener(void) const
3282 return __pTextSearchListener;
3287 _WebImpl::SetEventListenerCallback(void) const
3289 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3292 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3293 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3295 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3296 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3298 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3299 SysAssertf(pSmartData, "Failed to request");
3301 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3302 SysAssertf(pSmart, "Failed to request");
3304 pSmart->popup_menu_show = OnSelectBoxRequested;
3305 pSmart->popup_menu_hide = OnSelectBoxClosed;
3306 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3308 pSmart->input_picker_show = OnDatePickerProviderRequested;
3309 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3310 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3312 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3314 // add loading event callbacks for ILoadingListener
3315 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3316 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3318 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3319 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3320 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3321 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3322 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3323 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3324 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3325 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3326 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3328 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3330 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3332 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3333 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3334 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3336 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3337 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3339 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3341 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3342 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3343 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3345 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3347 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3348 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3349 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3351 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3352 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3353 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3355 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3356 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3357 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3359 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3360 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3361 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3362 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3364 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3365 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3367 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3369 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3370 SysAssertf(pContext, "Failed to get webkit instance.");
3371 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3372 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3374 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3380 _WebImpl::RemoveEventListenerCallback(void) const
3382 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3385 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3386 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3388 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3389 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3391 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3392 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3394 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3395 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3396 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3397 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3398 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3399 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3400 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3401 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3403 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3405 evas_object_smart_callback_del(pWinObject, "focus,in", OnWindowObjectFocusGained);
3407 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3408 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3409 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3411 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3412 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3414 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3416 ewk_view_javascript_alert_callback_set(null, null, null);
3417 ewk_view_javascript_prompt_callback_set(null, null, null);
3418 ewk_view_javascript_confirm_callback_set(null, null, null);
3420 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3422 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3423 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3424 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3426 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3427 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3428 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3429 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3430 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3431 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3433 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3434 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3435 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3437 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3439 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3440 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3442 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3444 ewk_view_open_panel_callback_set(null, null, null);
3446 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3452 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3454 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3456 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3457 SysAssertf(pSmartData, "Failed to request");
3459 Point absPoint(__pWebCore->GetAbsoluteCoordinate(startPoint));
3461 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3464 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3466 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3467 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3469 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3471 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3473 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3477 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3484 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3486 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToInteger(startPoint));
3491 _WebImpl::ReleaseBlock(void)
3493 ewk_view_command_execute(__pWebCore->GetWebNativeNode(), "Unselect", 0);
3498 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3500 FloatPoint tempStartPoint;
3501 FloatPoint tempEndPoint;
3503 GetBlockRange(tempStartPoint, tempEndPoint);
3505 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3506 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3511 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3513 Eina_Rectangle leftHandle;
3514 Eina_Rectangle rightHandle;
3516 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3518 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3519 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3520 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3521 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3523 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3525 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3526 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3532 _WebImpl::GetFaviconN(void) const
3534 result r = E_SUCCESS;
3536 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3538 Evas* pEvas = evas_object_evas_get(pView);
3539 Ewk_Context* pContext = ewk_view_context_get(pView);
3540 SysAssertf(pEvas && pContext, "Failed to request");
3542 const char* pUrl = ewk_view_url_get(pView);
3544 Tizen::Graphics::BufferInfo bufferInfo;
3545 Tizen::Base::ByteBuffer byteBuffer;
3547 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3548 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3550 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3556 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3557 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3559 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3561 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3562 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3564 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3565 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3567 return pBitmapImage.release();
3573 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3575 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3580 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3582 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3587 _WebImpl::GetScrollPosition(void) const
3591 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3598 _WebImpl::GetPageSize(void) const
3600 Evas_Coord width = 0;
3601 Evas_Coord height = 0;
3603 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3605 Dimension size(static_cast< int >(width), static_cast< int >(height));
3612 _WebImpl::SetLoadingErrorOccurred(bool arg)
3614 __isLoadingErrorOccurred = arg;
3619 _WebImpl::IsLoadingErrorOccurred(void) const
3621 return __isLoadingErrorOccurred;
3626 _WebImpl::SetRedirectRequested(bool arg)
3628 __isRedirectRequested = arg;
3633 _WebImpl::IsRedirectRequested(void) const
3635 return __isRedirectRequested;
3640 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3647 _WebImpl::GetPolicyDecision(void) const
3654 _WebImpl::SetCertificateRequested(bool arg)
3656 __isCertificateRequested = arg;
3661 _WebImpl::IsCertificateRequested(void) const
3663 return __isCertificateRequested;
3668 _WebImpl::IsCertificateConfirmed(void) const
3670 return __isCertificateConfirmed;
3675 _WebImpl::LaunchAppControl(const IEventArg& arg)
3677 result r = E_SUCCESS;
3679 IEventArg* pArg = const_cast< IEventArg* >(&arg);
3680 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
3681 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
3683 String operationId(L"");
3684 String uriPattern(pWebEventArg->GetEventMessage());
3685 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
3687 switch (pWebEventArg->GetEventType())
3689 case WEB_EVENT_REQUEST_RTSP:
3693 int uriLength = uriPattern.GetLength();
3696 operationId = L"http://tizen.org/appcontrol/operation/view";
3698 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
3699 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3701 r = uriPattern.SubString(index + 1, ext);
3702 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3704 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
3705 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3707 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
3708 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3712 case WEB_EVENT_REQUEST_TEL:
3714 operationId = L"http://tizen.org/appcontrol/operation/dial";
3717 case WEB_EVENT_REQUEST_EMAIL:
3719 case WEB_EVENT_REQUEST_SMS:
3721 case WEB_EVENT_REQUEST_MMS:
3723 operationId = L"http://tizen.org/appcontrol/operation/compose";
3726 case WEB_EVENT_REQUEST_UNKNOWN:
3728 operationId = L"http://tizen.org/appcontrol/operation/view";
3736 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
3737 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3744 _WebImpl::SetFullScreenKeypad(void)
3746 result r = E_SUCCESS;
3748 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3749 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3751 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3752 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3754 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3755 pKeypad->SetText(text);
3757 r = pKeypad->SetShowState(true);
3758 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3760 r = pKeypad->Show();
3761 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3763 pKeypad->AddTextEventListener(*this);
3765 __pKeypad = std::move(pKeypad);
3772 _WebImpl::RemoveFullScreenKeypad(void)
3774 __pKeypad->RemoveTextEventListener(*this);
3781 _WebImpl::IsFooterVisible(void) const
3783 return __isFooterVisible;
3788 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3790 __isFooterVisible = isFooterVisible;
3795 _WebImpl::IsKeypadVisible(void) const
3797 return __isKeypadVisible;
3802 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3804 __isKeypadVisible = isKeypadVisible;
3809 _WebImpl::IsKeypadOpened(void) const
3811 return __isKeypadOpened;
3815 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
3817 __isKeypadOpened = isKeypadOpened;
3822 _WebImpl::GetPreviousKeypadBounds(void) const
3824 return __keypadBounds;
3829 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
3831 __keypadBounds = bounds;
3836 _WebImpl::OnTextValueChangeCanceled(const Control& source)
3838 RemoveFullScreenKeypad();
3843 _WebImpl::OnTextValueChanged(const Control& source)
3845 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
3847 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
3849 RemoveFullScreenKeypad();
3854 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
3856 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
3857 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
3859 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
3860 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3862 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
3863 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
3865 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
3872 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
3874 result r = E_SUCCESS;
3876 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
3877 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3879 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3881 ILoadingListener* pLoadingListner = GetLoadingListener();
3882 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
3884 switch (pEventArg->GetEventType())
3886 case WEB_EVENT_LOADINGLISTENER_STARTED:
3888 pLoadingListner->OnLoadingStarted();
3892 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
3894 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
3895 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3897 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
3901 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
3903 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
3904 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3906 pLoadingListner->OnPageTitleReceived(*pPageTitle);
3910 case WEB_EVENT_LOADINGLISTENER_CANCELED:
3912 pLoadingListner->OnLoadingCanceled();
3916 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
3918 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
3919 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3921 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
3922 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3924 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
3926 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
3930 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
3932 pLoadingListner->OnLoadingCompleted();
3936 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
3938 pLoadingListner->OnHttpAuthenticationCanceled();
3942 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
3944 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
3945 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3949 pLoadingListner->OnFaviconReceived(*pFavicon.get());
3965 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
3967 result r = E_SUCCESS;
3969 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
3970 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3972 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3974 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
3975 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
3977 switch (pEventArg->GetEventType())
3979 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
3981 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
3982 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3984 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
3988 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
3990 pWebDownloadListener->OnWebDataDownloadCompleted();
3994 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
3996 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
3997 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3999 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4001 pWebDownloadListener->OnWebDownloadFailed(errorType);
4016 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4018 result r = E_SUCCESS;
4020 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4021 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4023 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4025 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4027 switch (pEventArg->GetEventType())
4029 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4031 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4033 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4034 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4036 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4037 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4039 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4043 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4045 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4047 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4051 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4053 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4055 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4059 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4061 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4063 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4064 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4066 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4081 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4083 result r = E_SUCCESS;
4085 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4086 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4088 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4090 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4092 switch (pEventArg->GetEventType())
4094 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4096 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4098 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4099 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4101 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4102 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4104 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4108 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4110 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4112 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4116 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4118 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4120 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4124 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4126 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4128 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4129 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4131 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4146 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4148 result r = E_SUCCESS;
4150 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4151 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4153 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4155 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4156 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4158 switch (pEventArg->GetEventType())
4160 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4162 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4163 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4165 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4166 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4168 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4183 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4185 result r = E_SUCCESS;
4187 String host(ewk_auth_challenge_url_get(pChallenge));
4188 String realm(ewk_auth_challenge_realm_get(pChallenge));
4190 __pAuthChallenge.reset();
4192 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4193 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4195 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4196 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4198 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4199 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4201 __pAuthChallenge = std::move(pAuthChallenge);
4203 ewk_auth_challenge_suspend(pChallenge);
4204 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4206 __pAuthChallenge.release();
4210 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4211 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4219 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4221 result r = E_SUCCESS;
4223 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4224 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4226 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4227 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4229 __pAuthPopup = std::move(pAuthPopup);
4231 int modalResult = 0;
4232 r = __pAuthPopup->ShowAndWait(modalResult);
4233 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4236 __pAuthPopup.reset();
4243 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4245 result r = E_SUCCESS;
4247 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4248 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4250 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4251 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4253 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4255 int modalResult = 0;
4256 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4257 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4259 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4261 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4265 __pCertConfirmPopup.reset();
4271 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy)
4273 result r = E_SUCCESS;
4275 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4276 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4278 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true);
4279 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4281 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4283 int modalResult = 0;
4284 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4285 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4288 __pUserConfirmPopup.reset();
4294 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy)
4296 result r = E_SUCCESS;
4298 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4299 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4301 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false);
4302 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4304 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4306 r = __pUserConfirmPopup->ShowPopup();
4307 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4309 __pUserConfirmPopup.release();
4314 __pUserConfirmPopup.reset();
4321 _WebImpl::GetParentFormCore(_Control* pControlCore)
4324 _Form* pFormCore = null;
4326 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4328 if (pParentControlCore == null)
4330 _Window* pWindowCore = dynamic_cast< _Window* >(pControlCore);
4331 SysAssertf(pWindowCore, "Failed to get parent control and window core.");
4332 pFormCore = dynamic_cast< _Form* >(pWindowCore->GetOwner());
4333 if (pFormCore == null)
4335 pParentControlCore = dynamic_cast< _Control* >(pWindowCore->GetOwner());
4336 SysTryReturn(NID_WEB_CTRL, pParentControlCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4341 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4344 if (pFormCore != null)
4349 return GetParentFormCore(pParentControlCore);
4354 _WebImpl::OnFocusGained(const _ControlImpl& source)
4361 _WebImpl::OnFocusLost(const _ControlImpl& source)
4363 if(IsKeypadVisible() == true)
4365 SetKeypadOpened(true);
4368 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4375 _WebImpl::HasValidNativeNode(void) const
4377 if (__pWebCore && __pWebCore->GetWebNativeNode())
4387 _WebImpl::OnAttachedToMainTree(void)
4389 result r = E_SUCCESS;
4391 r = __pWebCore->InitializeWebNativeNode();
4392 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4394 r = InitializeSetting();
4395 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4397 r = _ContainerImpl::OnAttachedToMainTree();
4398 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4405 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4407 _ContainerImpl::OnChangeLayout(orientation);
4409 if (IsKeypadVisible() == true)
4415 ecore_imf_context_input_panel_geometry_get(ecore_imf_context_add(ecore_imf_context_default_id_get()), &x, &y, &w, &h);
4417 _Form* pFormCore = GetParentFormCore(dynamic_cast< _Control* >(&this->GetCore()));
4418 SysAssertf(pFormCore != null, "Failed to get FormCore");
4420 pFormCore->DeflateClientRectHeight(h);
4423 if (__pColorPicker.get())
4425 __pColorPicker->ChangeLayout(orientation);
4431 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4433 if (IsVisible() == true)
4435 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4439 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4445 _WebImpl::GetDownloadHandler(void) const
4447 return __pWebDownloadHandler.get();
4452 _WebImpl::HideColorPicker(void)
4454 __pColorPicker.reset();
4461 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4463 result r = E_SUCCESS;
4465 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4466 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4468 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4470 r = pColorHadler->Construct(colorVal);
4471 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4473 __pColorPicker = std::move(pColorHadler);
4475 r = __pColorPicker->ShowPopup();
4476 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4478 color = __pColorPicker->GetColor();
4483 __pColorPicker.reset();
4490 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4492 result r = E_SUCCESS;
4494 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4495 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4497 r = pInputPicker->Construct(String(inputValue), inputType);
4498 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4500 __pDatePicker = std::move(pInputPicker);
4502 r = __pDatePicker->ShowPopup();
4503 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4505 dateStr = __pDatePicker->GetDate();
4508 __pDatePicker.reset();
4515 _WebImpl::GetInstance(Web* pWeb)
4517 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4522 _WebImpl::GetInstance(const Web* pWeb)
4524 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4528 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4530 int checkReturn = 0;
4532 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4535 if( checkmime == true)
4537 table = CUSTOM_CONTENT_TABLE_NAME;
4541 table = CUSTOM_PROTOCOL_TABLE_NAME;
4544 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4545 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4546 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4548 SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4550 result r = db.Construct(handlerPath, "r+", null);
4551 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4553 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"'"));
4554 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4558 r = pEnum->MoveNext();
4559 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4560 r = pEnum->GetIntAt(0, checkReturn);
4561 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4572 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4576 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4579 if( checkmime == true)
4581 table = CUSTOM_CONTENT_TABLE_NAME;
4585 table = CUSTOM_PROTOCOL_TABLE_NAME;
4588 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4589 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4590 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4592 SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4594 result r = db.Construct(handlerPath, "r+", null);
4595 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4597 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"'"));
4598 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4602 r = pEnum->MoveNext();
4603 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4604 r = pEnum->GetIntAt(0, checkId);
4605 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4607 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
4608 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4610 r = pDeleteStmt->BindInt(0, checkId);
4611 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4613 db.BeginTransaction();
4615 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
4617 db.CommitTransaction();
4623 const Tizen::Base::String
4624 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
4626 SysAssertf(currentUri != null, "Failed to get currenturi");
4628 result r = E_SUCCESS;
4631 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4632 String originReplace(originUri);
4633 String table(CUSTOM_PROTOCOL_TABLE_NAME);
4637 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4638 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4640 r = currentUri.SubString(0, found + 1, baseUri);
4641 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4643 r = db.Construct(handlerPath, "r+", null);
4644 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4646 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
4647 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
4651 while (pEnum->MoveNext() == E_SUCCESS)
4656 String originScheme;
4658 r = pEnum->GetStringAt(0, protocol);
4659 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4661 r = pEnum->GetStringAt(1, queryUrl);
4662 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4664 r = pEnum->GetIntAt(2, allow);
4665 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4672 String protocolScheme(protocol + L":");
4674 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
4675 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4677 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
4679 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
4681 r = originReplace.Replace(originScheme, "");
4682 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4684 queryUrl.Replace("%s", originReplace, 0);
4685 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4697 const Tizen::Base::String
4698 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
4700 SysAssertf(currentUri != null, "Failed to get currenturi");
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));
4752 }}} // Tizen::Web::Controls