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 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
622 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
623 SysAssertf(pImpl && pHandlerData, "Failed to request");
625 ewk_custom_handlers_data_target_get(pHandlerData);
626 ewk_custom_handlers_data_base_url_get(pHandlerData);
627 ewk_custom_handlers_data_url_get(pHandlerData);
628 ewk_custom_handlers_data_title_get(pHandlerData);
633 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
635 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
636 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
637 SysAssertf(pImpl && pHandlerData, "Failed to request");
639 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
644 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
646 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
647 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
648 SysAssertf(pImpl && pHandlerData, "Failed to request");
653 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
655 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
656 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
657 SysAssertf(pImpl && pHandlerData, "Failed to request");
662 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
664 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
665 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
666 SysAssertf(pImpl && pHandlerData, "Failed to request");
668 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
673 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
675 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
676 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
677 SysAssertf(pImpl && pHandlerData, "Failed to request");
682 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
684 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
685 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
686 SysAssertf(pImpl && pPolicy, "Failed to request");
688 String url(ewk_policy_decision_url_get(pPolicy));
689 SysLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
691 if (url == L"about:blank")
693 ewk_policy_decision_use(pPolicy);
697 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
698 && !pImpl->IsRedirectRequested())
700 pImpl->SetCertificateRequested(false);
702 if (pImpl->GetTextSearchListener())
704 pImpl->DisableAsyncSearch();
707 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
708 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
710 switch (ewkNavigationType)
712 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
713 navigationType = WEB_NAVIGATION_LINK_CLICKED;
715 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
716 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
718 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
719 navigationType = WEB_NAVIGATION_BACKFORWARD;
721 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
722 navigationType = WEB_NAVIGATION_RELOAD;
724 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
725 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
727 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
728 navigationType = WEB_NAVIGATION_OTHER;
734 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
736 ewk_policy_decision_ignore(pPolicy);
745 String uriScheme(uri.GetScheme());
746 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
748 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
750 ewk_policy_decision_ignore(pPolicy);
752 if (uriScheme == L"")
757 result r = E_SUCCESS;
759 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
761 if (uriScheme == L"rtsp")
763 eventType = WEB_EVENT_REQUEST_RTSP;
765 else if (uriScheme == L"mailto")
767 eventType = WEB_EVENT_REQUEST_EMAIL;
769 else if (uriScheme == L"tel")
771 eventType = WEB_EVENT_REQUEST_TEL;
773 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
775 eventType = WEB_EVENT_REQUEST_SMS;
777 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
779 eventType = WEB_EVENT_REQUEST_MMS;
782 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
783 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
785 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
786 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
792 ewk_policy_decision_use(pPolicy);
797 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
799 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
800 SysAssertf(pImpl, "Failed to request");
802 if (pImpl->GetLoadingListener())
804 result r = E_SUCCESS;
806 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
807 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
809 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
810 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
817 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
819 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
820 char* pTitle = reinterpret_cast< char* >(pEventInfo);
821 SysAssertf(pImpl, "Failed to request");
823 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
825 if (pImpl->GetLoadingListener())
827 result r = E_SUCCESS;
829 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
830 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
831 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
833 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
834 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
835 pPageTitle.release();
837 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
838 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
845 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
847 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
848 double* pProgress = reinterpret_cast< double* >(pEventInfo);
849 SysAssertf(pImpl, "Failed to request");
851 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
853 if (pImpl->GetLoadingListener())
855 result r = E_SUCCESS;
857 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
858 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
859 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
861 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
862 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
863 pProgressPercentage.release();
865 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
866 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
873 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
875 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
876 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
877 SysAssertf(pImpl && pPolicy, "Failed to request");
879 result r = E_SUCCESS;
881 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
882 int code = ewk_policy_decision_response_status_code_get(pPolicy);
883 String mime(ewk_policy_decision_response_mime_get(pPolicy));
884 SysLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
886 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
887 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
889 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
891 DecisionPolicy policy;
892 HttpHeader httpHeader;
894 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
896 pImpl->SetRedirectRequested(true);
900 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
901 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
903 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
904 pImpl->SetPolicyDecision(policy);
907 switch (pImpl->GetPolicyDecision())
909 case WEB_DECISION_CONTINUE:
911 if (pImpl->IsMimeSupported(mime) || mime == L"")
918 SysLog(NID_WEB_CTRL, "Lauch native app to handle the mime");
920 ewk_policy_decision_ignore(pPolicy);
922 AppControl* pAppControl = null;
923 _SelectBox selectBox;
925 int selectedIndex = 0;
927 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
931 appCount = pList->GetCount();
934 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
935 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
937 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
938 for (int i = 0; i < appCount; i++)
940 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
941 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
943 String text = pAppControl->GetAppName();
944 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
946 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
948 r = selectBox.ShowAndWait(selectedIndex);
949 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
951 if (selectedIndex == 0) //download
954 DownloadRequest request(pUrl);
956 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
957 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
959 r = pManagerImpl->Start(request, reqId);
960 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
962 else if (selectedIndex != -1) // -1 for cancel
965 String pathVal(pUrl);
968 r = dataList.Construct();
969 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
971 r = dataList.Add(path, pathVal);
972 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
974 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
975 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
977 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
978 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
980 r = pAcImpl->Start(null, null, &dataList, null);
981 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
988 case WEB_DECISION_DOWNLOAD:
990 ewk_policy_decision_ignore(pPolicy);
992 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
993 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
995 Ewk_Context* pContext = ewk_view_context_get(pView);
996 SysAssertf(pContext, "Failed to get webkit instance.");
998 pDownloadHandler->StartDownload(pUrl);
1002 case WEB_DECISION_IGNORE:
1004 ewk_policy_decision_ignore(pPolicy);
1014 ewk_policy_decision_use(pPolicy);
1019 ewk_policy_decision_ignore(pPolicy);
1024 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1026 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1027 SysAssertf(pImpl, "Failed to request");
1029 if (pImpl->IsRedirectRequested())
1031 pImpl->SetRedirectRequested(false);
1034 if (pImpl->IsLoadingErrorOccurred())
1036 pImpl->SetLoadingErrorOccurred(false);
1037 evas_object_smart_callback_call(pView, "load,finished", NULL);
1043 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1045 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1046 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1047 SysAssertf(pImpl && pErrorData, "Failed to request");
1049 int code = ewk_error_code_get(pErrorData);
1050 const char* pDescription = ewk_error_description_get(pErrorData);
1052 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1054 pImpl->SetLoadingErrorOccurred(true);
1057 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1059 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1062 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1063 evas_object_smart_callback_call(pView, "load,stop", NULL);
1067 if (pImpl->GetLoadingListener())
1069 result r = E_SUCCESS;
1071 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1072 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1080 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1082 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1083 SysAssertf(pImpl, "Failed to request");
1085 if (pImpl->GetLoadingListener())
1087 result r = E_SUCCESS;
1089 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1090 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1092 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1093 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1094 pEventArg.release();
1101 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1103 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1104 SysAssertf(pImpl, "Failed to request");
1106 if (pImpl->GetLoadingListener())
1108 result r = E_SUCCESS;
1110 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1111 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1113 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1114 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1115 pEventArg.release();
1122 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1124 evas_object_focus_set(pView, EINA_FALSE);
1129 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1131 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1132 SysAssertf(pImpl, "Failed to request");
1134 if (pImpl->GetLoadingListener())
1136 result r = E_SUCCESS;
1138 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1139 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1141 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1142 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1143 pEventArg.release();
1150 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1152 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1153 SysAssertf(pUrl && pImpl != null, "Failed to request");
1155 SysLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1160 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1162 result r = E_SUCCESS;
1164 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1165 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1167 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1168 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1169 pEventArg.release();
1176 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1178 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1179 SysAssertf(pImpl, "Failed to request");
1181 if (pImpl->GetUiEventListener())
1183 result r = E_SUCCESS;
1185 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1186 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1188 if (pImpl->GetUiEventListenerF())
1190 result r = E_SUCCESS;
1192 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1193 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1199 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1201 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1202 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1203 SysAssertf(pParentImpl && pChildView, "Failed to request");
1205 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1206 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1207 if (pUserUiListener)
1209 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1212 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1213 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1215 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1216 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1219 if (pUserUiListenerF)
1221 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1224 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1225 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1227 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1228 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1235 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1237 result r = E_SUCCESS;
1239 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1240 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1242 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1243 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1244 pEventArg.release();
1251 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1253 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1254 SysAssertf(pChildImpl, "Failed to request");
1256 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1257 if (pParentImpl == null)
1262 if (pParentImpl->GetUiEventListener())
1264 result r = E_SUCCESS;
1266 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1267 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1269 if (pParentImpl->GetUiEventListenerF())
1271 result r = E_SUCCESS;
1273 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1274 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1280 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1282 result r = E_SUCCESS;
1284 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1285 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1286 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1288 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1289 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1290 pPreventTrigger.release();
1292 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1293 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1294 pEventArg.release();
1301 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1303 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1304 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1305 SysAssertf(pImpl && pTrigger, "Failed to request");
1307 if (pImpl->GetUiEventListener())
1309 result r = E_SUCCESS;
1311 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1312 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1314 if (pImpl->GetUiEventListenerF())
1316 result r = E_SUCCESS;
1318 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1319 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1325 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1327 result r = E_SUCCESS;
1329 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1330 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1331 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1333 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1335 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1336 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1338 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1339 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1340 startPoint.release();
1342 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1343 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1346 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1347 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1348 pEventArg.release();
1355 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1357 result r = E_SUCCESS;
1359 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1360 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1362 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1364 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1366 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1367 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1369 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1370 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1371 startPoint.release();
1373 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1374 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1377 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1378 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1379 pEventArg.release();
1386 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1388 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1389 Ewk_Text_Style* pStyle = reinterpret_cast< Ewk_Text_Style* >(pEventInfo);
1390 SysAssertf(pImpl && pStyle, "Failed to request");
1392 if (pImpl->GetUiEventListener())
1394 result r = E_SUCCESS;
1396 r = FireWebPageBlockSelectedEvent(pImpl);
1397 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1399 if (pImpl->GetUiEventListenerF())
1401 result r = E_SUCCESS;
1403 r = FireWebPageBlockSelectedEventF(pImpl);
1404 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1410 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1412 Eina_Bool ret = EINA_FALSE;
1413 Eina_List* pSelectedFileNames = null;
1414 String isMultipleSelection(L"single");
1418 isMultipleSelection.Append(L"multiple");
1421 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1422 SysTryCatch(NID_WEB_CTRL, pMediaListener.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1425 int itemCount = eina_list_count(pAcceptTypes);
1426 String fileType = L"all";
1430 String item((char*)eina_list_nth(pAcceptTypes, 0));
1431 if (item.StartsWith("image/",0))
1433 fileType = L"image";
1435 else if (item.StartsWith("audio/",0))
1437 fileType = L"audio";
1439 else if (item.StartsWith("video/",0))
1441 fileType = L"video";
1446 result r = dataList.Construct();
1447 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1449 String mode(L"selectionType");
1450 r = dataList.Add(mode, isMultipleSelection);
1451 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1453 String type(L"type");
1454 r = dataList.Add(type, fileType);
1455 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1457 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1458 SysTryCatch(NID_WEB_CTRL, pMediaAppControl.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1460 _AppControlImpl* pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl);
1461 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1462 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1466 if (pMediaListener->IsSelectionCompleted())
1468 const ArrayList* pSelectedFiles = pMediaListener->GetSelectedFiles();
1469 SysTryCatch(NID_WEB_CTRL, pSelectedFiles, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1471 int fileCount = pSelectedFiles->GetCount();
1473 for (int i = 0; i < fileCount; i++)
1475 String* pFile = (String*)pSelectedFiles->GetAt(i);
1476 SysTryCatch(NID_WEB_CTRL, pFile, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1478 std::unique_ptr<ByteBuffer> pByteBuf(StringUtil::StringToUtf8N(*pFile));
1479 SysTryCatch(NID_WEB_CTRL, pByteBuf.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1481 pSelectedFileNames = eina_list_append(pSelectedFileNames, strdup((const char*)pByteBuf->GetPointer()));
1488 ecore_main_loop_iterate();
1491 ewk_view_open_panel_reply(pView, pSelectedFileNames, ret);
1496 ewk_view_open_panel_reply(pView, null, ret);
1497 eina_list_free(pSelectedFileNames);
1503 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1505 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1506 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1507 SysAssertf(pImpl && pJsonText, "Failed to request");
1509 result r = E_SUCCESS;
1511 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1513 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1514 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1516 r = pEventArg->Construct(pJsonText);
1517 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1519 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1520 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1521 pEventArg.release();
1526 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1528 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1529 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1530 SysAssertf(pImpl && pEinaRect, "Failed to request");
1532 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1534 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1535 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1537 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1539 if (rect.height == 0)
1544 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1545 SysAssertf(pFormCore != null, "Failed to get FormCore");
1547 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1549 pImpl->SetFooterVisibleState(true);
1550 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1553 if (pImpl->GetWebKeypadEventListener())
1555 if (pImpl->IsKeypadVisible() == true)
1557 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1559 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1564 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1565 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1568 pImpl->SetKeypadVisibleState(true);
1569 pImpl->SetPreviousKeypadBounds(rect);
1573 result r = pImpl->SetFullScreenKeypad();
1574 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1580 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1582 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1583 SysAssertf(pImpl, "Failed to request");
1585 if (pImpl->GetWebKeypadEventListener())
1587 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1593 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1595 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1596 SysAssertf(pImpl, "Failed to request");
1598 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1599 SysAssertf(pFormCore != null, "Failed to get FormCore");
1601 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1603 pImpl->SetFooterVisibleState(false);
1604 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1607 pFormCore->DeflateClientRectHeight(0);
1609 if (pImpl->GetWebKeypadEventListener())
1611 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1614 pImpl->SetKeypadVisibleState(false);
1619 OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info)
1621 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1622 SysAssertf(pImpl, "Failed to request");
1624 if (pImpl->IsKeypadOpened() == true)
1626 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1627 SysAssertf(pWebCore, "Failed to get Web core object");
1629 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1631 pImpl->SetKeypadOpened(false);
1637 OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo)
1639 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1640 SysAssertf(pImpl, "Failed to request");
1642 if (pImpl->IsKeypadOpened() == true)
1644 pImpl->SetKeypadOpened(false);
1650 OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha)
1652 SysAssertf(pSmartData, "invalid smartdata");
1653 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1654 SysAssertf(pWebImpl, "Failed to get Impl");
1656 result r = E_SUCCESS;
1658 if (pWebImpl->GetColorpicker())
1665 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1666 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1668 byte r1, g1, b1, a1;
1669 color.GetColorComponents(r1, g1, b1, a1);
1670 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1677 OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData)
1679 SysAssertf(pSmartData, "invalid smartdata");
1681 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1682 SysAssertf(pWebImpl, "Failed to get Impl");
1684 return pWebImpl->HideColorPicker();
1689 OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1691 SysAssertf(pSmartData, "Failed to request");
1692 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1693 SysAssertf(pWebImpl, "Failed to get Impl");
1695 result r = E_SUCCESS;
1697 if (pWebImpl->GetDatepicker())
1699 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1706 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1707 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1709 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1710 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1712 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1719 OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1721 SysAssertf(pSmartData, "Failed to request");
1723 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1724 SysAssertf(pWebImpl, "Failed to get Impl");
1726 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1727 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1734 OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData)
1736 SysAssertf(pSmartData, "invalid smartdata");
1738 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1739 SysAssertf(pWebImpl, "Failed to get Impl");
1741 result r = pWebImpl->ClearSelectBoxPopup();
1742 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1749 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1751 SysAssertf(pSmartData, "invalid smartdata");
1753 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1754 SysAssertf(pWebImpl, "Failed to get Impl");
1756 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1757 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1764 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1766 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1767 SysAssertf(pPresenter && !pError, "Failed to request");
1769 bool ret = EINA_TRUE;
1773 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1775 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1779 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1788 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1790 pPresenter->EndAsyncProcess(ret);
1795 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1797 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1798 SysAssertf(pPresenter, "Failed to request");
1800 String result(pResult);
1801 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1803 pPresenter->EndAsyncProcess(result);
1808 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
1810 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1811 SysAssertf(pImpl, "Failed to request");
1813 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
1814 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
1816 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
1820 pWebPresenter->EndAsyncProcess(*pTotalCount);
1824 if (pImpl->GetTextSearchListener())
1826 result r = E_SUCCESS;
1830 if (*pTotalCount > 0)
1832 ordinal = pImpl->GetAsyncSearchOrdinal();
1833 pImpl->SetAsyncSearchResult(*pTotalCount);
1836 if (pImpl->GetPendingAsyncSearchCount() > 0)
1841 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
1842 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
1843 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
1844 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1846 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
1847 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1850 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
1851 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1854 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1855 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1856 pEventArg.release();
1862 class _JsBridgeHashCodeProvider
1863 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
1866 _JsBridgeHashCodeProvider(){}
1867 virtual ~_JsBridgeHashCodeProvider(void) {}
1870 int GetHashCode(const Tizen::Base::String& obj) const
1872 return obj.GetHashCode();
1878 //Comparer implementation
1879 class _JsBridgeComparer
1880 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
1883 _JsBridgeComparer(){}
1884 virtual ~_JsBridgeComparer(void) {}
1887 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
1904 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
1905 : _ContainerImpl(pWeb, pCore)
1906 , __isFooterVisible(false)
1907 , __isKeypadVisible(false)
1908 , __isKeypadOpened(false)
1909 , __isLoadingErrorOccurred(false)
1910 , __isRedirectRequested(false)
1911 , __isCertificateRequested(false)
1912 , __isCertificateConfirmed(false)
1913 , __keypadBounds(0, 0, 0, 0)
1915 , __pUserLoadingListener(null)
1916 , __pUserUiListener(null)
1917 , __pUserUiListenerF(null)
1918 , __pUserKeypadEventListener(null)
1919 , __pTextSearchListener(null)
1921 , __pJsBridgeList(null)
1922 , __pJsProvider(null)
1923 , __pJsComparer(null)
1924 , __pWebDownloadHandler(null)
1926 , __pAuthChallenge(null)
1927 , __pAuthPopup(null)
1928 , __pUserConfirmPopup(null)
1929 , __pCertConfirmPopup(null)
1930 , __pSelectBox(null)
1931 , __pDatePicker(null)
1932 , __pColorPicker(null)
1933 , __policy(WEB_DECISION_CONTINUE)
1935 __textSearch.__searchAll = false;
1936 __textSearch.__searchForward = true;
1937 __textSearch.__caseSensitive = false;
1938 __textSearch.__pending = 0;
1939 __textSearch.__currentIndex = 1;
1940 __textSearch.__totalCount = -1;
1941 __textSearch.__text = L"";
1945 _WebImpl::~_WebImpl()
1947 RemoveEventListenerCallback();
1951 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
1953 result r = E_SUCCESS;
1955 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
1956 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1958 _Web* pCore = _Web::CreateWebN();
1959 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1961 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
1963 r = CheckConstruction(pCore, pImpl);
1964 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1966 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
1967 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1969 r = pImpl->Construct();
1970 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1982 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
1984 result r = E_SUCCESS;
1986 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
1987 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1989 _Web* pCore = _Web::CreateWebN();
1990 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1992 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
1994 r = CheckConstruction(pCore, pImpl);
1995 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1997 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
1998 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2000 r = pImpl->Construct();
2001 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2013 _WebImpl::Construct(void)
2015 result r = E_SUCCESS;
2017 r = __mutex.Create();
2018 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2020 r = __textSearch.__searchQueue.Construct();
2021 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2023 r = InitJsBridgeList();
2024 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2027 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2029 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2030 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2037 _WebImpl::InitializeSetting(void)
2039 result r = E_SUCCESS;
2041 r = SetSetting(*__pWebCore->GetSetting());
2042 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2044 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2046 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2047 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2048 SetZoomLevel(pWebSettingImpl->GetZoomLevel());
2050 SetEventListenerCallback();
2052 _Form* pFormCore = GetParentFormCore(dynamic_cast< _Control* >(&this->GetCore()));
2053 SysAssertf(pFormCore != null, "Failed to get FormCore");
2060 _WebImpl::IsLayoutable(void) const
2067 _WebImpl::InitWebEvent(void)
2069 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2070 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2072 return __pWebEvent->Construct(*this);
2077 _WebImpl::GetWebEvent(void) const
2079 return __pWebEvent.get();
2084 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2086 Eina_Hash* pHttpHeader = null;
2088 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2089 if (pFieldNameList.get())
2091 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2092 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2094 int count = pFieldNameList->GetCount();
2096 for (int i = 0; i < count; i++)
2098 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2099 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2101 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2102 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2104 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2105 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2107 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2109 Eina_Bool ret = false;
2111 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2112 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2114 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2115 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2117 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2118 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2125 eina_hash_free(pHttpHeader);
2132 _WebImpl::LoadUrl(const String& url) const
2134 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2135 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2137 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2144 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2146 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2147 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2149 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2151 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2153 eina_hash_free(pHttpHeader);
2160 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2162 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2163 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2165 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2167 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2169 eina_hash_free(pHttpHeader);
2176 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2178 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2180 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2181 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2182 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2183 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2185 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2192 _WebImpl::Pause(void)
2194 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2199 _WebImpl::Resume(void)
2201 ewk_view_resume(__pWebCore->GetWebNativeNode());
2206 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2208 __pSelectBox.reset();
2210 int itemCount = eina_list_count(pItems);
2211 SysTryReturnResult(NID_WEB_CTRL, itemCount > 0, E_SYSTEM, "ItemCount is invalid.");
2213 result r = E_SUCCESS;
2215 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2216 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2218 r = pSelectBox->Construct(isMultiSelect, title, itemCount, pWebView);
2219 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2221 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2222 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2224 __pSelectBox = std::move(pSelectBox);
2226 return __pSelectBox->ShowPopup();
2231 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2233 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2235 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2240 _WebImpl::ClearSelectBoxPopup(void)
2242 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2244 __pSelectBox.reset();
2251 _WebImpl::GetDatepicker(void)
2253 _InputPickerPopup* pInputPicker =null;
2256 pInputPicker = __pDatePicker.get();
2258 return pInputPicker;
2263 _WebImpl::GetColorpicker(void)
2265 _InputPickerPopup* pInputPicker =null;
2268 pInputPicker = __pColorPicker.get();
2270 return pInputPicker;
2275 _WebImpl::CanGoBack(void) const
2277 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2282 _WebImpl::CanGoForward(void) const
2284 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2289 _WebImpl::GoBack(void) const
2291 ewk_view_back(__pWebCore->GetWebNativeNode());
2296 _WebImpl::GoForward(void) const
2298 ewk_view_forward(__pWebCore->GetWebNativeNode());
2303 _WebImpl::GetUrl(void) const
2305 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2310 _WebImpl::GetTitle(void) const
2312 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2317 _WebImpl::StopLoading(void) const
2319 ewk_view_stop(__pWebCore->GetWebNativeNode());
2324 _WebImpl::Reload(void) const
2326 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
2331 _WebImpl::EvaluateJavascriptN(const String& scriptCode) const
2333 if (scriptCode.GetLength())
2335 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2336 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2338 _WebPresenter presenter;
2339 presenter.InitAsyncProcess();
2341 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, &presenter);
2343 Tizen::Base::String* pResult = new (std::nothrow) Tizen::Base::String(L"");
2344 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2345 presenter.WaitAsyncProcess(*pResult);
2355 _WebImpl::SetZoomLevel(float level)
2357 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);
2359 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2366 _WebImpl::GetZoomLevel(void) const
2368 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2372 const PageNavigationList*
2373 _WebImpl::GetBackForwardListN(void) const
2375 result r = E_SUCCESS;
2377 _PageNavigationListImpl* pNavigationListImpl = null;
2378 _HistoryItemImpl* pHistoryItemImpl = null;
2380 std::unique_ptr<PageNavigationList> pNavigationList;
2381 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2384 int forwardCount = 0;
2389 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2390 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2392 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2393 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2395 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2396 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2398 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2399 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2401 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2402 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2404 r = pHistoryList->Construct();
2405 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2407 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2408 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2409 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2411 for (int i = -backCount; i < forwardCount + 1; i++)
2413 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2414 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2416 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2417 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2419 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2420 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2422 url = ewk_history_item_uri_get(pEwkItem);
2423 title = ewk_history_item_title_get(pEwkItem);
2424 SysLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2426 pHistoryItemImpl->SetHistoryItem(url, title);
2428 r = pHistoryList->Add(*pHistoryItem.get());
2429 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2430 pHistoryItem.release();
2433 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2435 ewk_history_free(pEwkHistoryList);
2437 return pNavigationList.release();
2440 ewk_history_free(pEwkHistoryList);
2447 _WebImpl::SearchText(const String& text, bool searchForward)
2449 result r = E_SUCCESS;
2451 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2455 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2458 _WebPresenter presenter;
2459 presenter.InitAsyncProcess();
2461 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2462 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2465 presenter.WaitAsyncProcess(result);
2467 return static_cast < bool >(result);
2472 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2474 result r = E_SUCCESS;
2476 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2480 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2483 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2484 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2491 _WebImpl::SearchNextAsync(bool searchForward)
2493 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2494 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2495 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2497 result r = E_SUCCESS;
2499 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2501 if (__textSearch.__caseSensitive)
2503 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2508 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2511 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2512 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2519 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2521 MutexGuard lock(__mutex);
2523 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2524 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2529 if (__textSearch.__searchAll)
2531 DisableAsyncSearch();
2533 __textSearch.__searchQueue.Enqueue(this);
2534 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2536 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2537 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2541 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2543 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2547 case SEARCH_ALL_ASYNC:
2548 __textSearch.__searchAll = true;
2549 __textSearch.__text = text;
2550 __textSearch.__searchForward = true;
2551 __textSearch.__caseSensitive = caseSensitive;
2552 __textSearch.__totalCount = -1;
2553 __textSearch.__currentIndex = 1;
2555 __textSearch.__searchQueue.Enqueue(this);
2556 __textSearch.__searchQueue.Enqueue(this);
2558 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2559 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2562 case SEARCH_NEXT_ASYNC:
2563 __textSearch.__searchForward = searchForward;
2565 CalculateAsyncSearchOrdinal();
2567 __textSearch.__searchQueue.Enqueue(this);
2569 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2581 _WebImpl::SetAsyncSearchResult(int totalCount)
2583 __textSearch.__totalCount = totalCount;
2588 _WebImpl::GetSearchPresenter(void)
2590 MutexGuard lock(__mutex);
2592 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2597 _WebImpl::GetPendingAsyncSearchCount(void) const
2599 return __textSearch.__searchQueue.GetCount();
2604 _WebImpl::CalculateAsyncSearchOrdinal(void)
2606 if (__textSearch.__searchForward)
2608 __textSearch.__currentIndex++;
2612 __textSearch.__currentIndex--;
2618 _WebImpl::GetAsyncSearchOrdinal(void) const
2620 return __textSearch.__currentIndex;
2625 _WebImpl::DisableAsyncSearch(void)
2627 __textSearch.__searchAll = false;
2632 _WebImpl::SetSetting(const WebSetting& setting)
2634 if (__pWebCore->GetWebNativeNode())
2636 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2637 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2638 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2640 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2641 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2643 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2645 switch (setting.GetCacheControl())
2647 case WEB_CACHE_VALIDATED:
2648 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2651 case WEB_CACHE_IGNORE:
2652 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2659 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2661 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2665 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2668 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2670 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2672 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2674 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2675 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2677 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2679 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2681 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2683 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2685 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2688 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2690 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2691 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2692 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2693 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2694 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2695 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2696 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2697 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2698 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2699 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2700 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2701 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2702 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2709 _WebImpl::GetSetting(void) const
2711 return *__pWebCore->GetSetting();
2715 const HitElementResult*
2716 _WebImpl::GetElementByPointN(const Point& point) const
2718 result r = E_SUCCESS;
2720 _HitElementResultImpl* pHitElementResultImpl = null;
2722 std::unique_ptr<HitElementResult> pHitElementResult;
2723 std::unique_ptr<Bitmap> pImage;
2724 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2726 Point absPoint(__pWebCore->GetAbsoluteCoordinate(point));
2728 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2729 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2731 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2732 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2733 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2734 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2735 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2737 SysLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2739 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2740 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2742 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2743 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2745 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
2751 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
2752 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
2753 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
2754 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
2756 r = buf.Construct(imageLength);
2757 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2759 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
2760 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2764 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
2765 // webkit support types such as ico and vp8 additionally
2766 if (strcmp(pExtension, "gif") == 0)
2768 format = IMG_FORMAT_GIF;
2770 else if (strcmp(pExtension, "jpg") == 0)
2772 format = IMG_FORMAT_JPG;
2774 else if (strcmp(pExtension, "png") == 0)
2776 format = IMG_FORMAT_PNG;
2778 else if (strcmp(pExtension, "bmp") == 0)
2780 format = IMG_FORMAT_BMP;
2784 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
2788 r = image.Construct();
2789 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2791 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
2792 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2797 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
2798 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2800 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
2801 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2803 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
2804 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2807 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
2809 ewk_hit_test_free(pEwkHitTest);
2811 return pHitElementResult.release();
2814 ewk_hit_test_free(pEwkHitTest);
2820 const HitElementResult*
2821 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2823 const Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
2825 std::unique_ptr<const HitElementResult> pHitElementResult(GetElementByPointN(integerPoint));
2826 SysTryReturn(NID_WEB_CTRL, pHitElementResult.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2828 return pHitElementResult.release();
2833 _WebImpl::IsLoading(void) const
2835 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
2837 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
2849 _WebImpl::GetTextFromBlock(void) const
2851 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
2856 _WebImpl::IsPrivateBrowsingEnabled(void) const
2858 if (__pWebCore->GetWebNativeNode() == null)
2860 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
2863 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2864 SysAssertf(pSettings, "Failed to get webkit instance.");
2866 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
2871 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
2873 if (__pWebCore->GetWebNativeNode() == null)
2875 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
2879 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2880 SysAssertf(pSettings, "Failed to get webkit instance.");
2882 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
2887 _WebImpl::ClearHistory(void)
2889 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
2894 _WebImpl::ClearCache(void)
2896 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2897 SysAssertf(pContext, "Failed to get webkit instance.");
2899 ewk_context_cache_clear(pContext);
2904 _WebImpl::ClearCookie(void)
2906 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2907 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2908 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2910 ewk_cookie_manager_cookies_clear(pCookieManager);
2915 _WebImpl::ClearFormData(void)
2917 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2918 SysAssertf(pContext, "Failed to get webkit instance.");
2920 ewk_context_form_candidate_data_clear(pContext);
2925 _WebImpl::ClearLoginFormData(void)
2927 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2928 SysAssertf(pContext, "Failed to get webkit instance.");
2930 ewk_context_form_password_data_clear(pContext);
2935 _WebImpl::IsCookieEnabled(void) const
2937 if (__pWebCore->GetWebNativeNode() == null)
2939 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
2942 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2943 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2944 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2946 _WebPresenter presenter;
2947 presenter.InitAsyncProcess();
2949 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
2951 bool result = false;
2952 presenter.WaitAsyncProcess(result);
2959 _WebImpl::SetCookieEnabled(bool enable)
2961 if (__pWebCore->GetWebNativeNode() == null)
2963 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
2968 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2969 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2970 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2974 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY);
2978 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
2979 ewk_cookie_manager_cookies_clear(pCookieManager);
2985 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
2987 result r = E_SUCCESS;
2989 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
2990 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2993 String fileExtension = File::GetFileExtension(filePath);
2994 int pathLength = filePath.GetLength();
2997 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
2999 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3000 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3001 r = filePath.SubString(0, index + 1, dirPath);
3002 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3004 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3005 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3009 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3011 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3015 Evas_Coord contentsWidth;
3016 Evas_Coord contentsHeight;
3018 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3019 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3027 _WebImpl::IsMimeSupported(const String& mime) const
3029 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3030 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3032 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3037 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3039 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3044 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3046 __pUserUiListener = pUiEventListener;
3051 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3053 __pUserUiListenerF = pUiEventListener;
3058 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3060 __pUserKeypadEventListener = pKeypadEventListener;
3065 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3067 if (__pWebDownloadHandler.get() == null)
3069 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3070 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3073 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3074 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3079 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3081 __pTextSearchListener = pTextSearchListener;
3086 _WebImpl::SetScrollEnabled(bool enable)
3088 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3093 _WebImpl::IsScrollEnabled(void) const
3095 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3100 _WebImpl::InitJsBridgeList(void)
3102 result r = E_SUCCESS;
3104 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3105 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3107 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3108 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3110 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3111 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3113 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3114 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3116 __pJsBridgeList = std::move(pJsBridgeList);
3123 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3125 result r = E_SUCCESS;
3127 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3128 String key(pJsBridge->GetName());
3130 r = __pJsBridgeList->Add(key, pJsBridge);
3131 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3138 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3140 result r = E_SUCCESS;
3142 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3143 String key(pJsBridge->GetName());
3145 r = __pJsBridgeList->Remove(key);
3146 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3153 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3155 result r = E_SUCCESS;
3157 IJsonValue* pJsonValue = null;
3158 IJavaScriptBridge* pJsBridge = null;
3160 String key(L"name");
3162 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3163 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));
3165 r = pJsonObject->GetValue(&key, pJsonValue);
3166 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3168 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3169 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3171 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3172 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3179 _WebImpl::GetLoadingListener(void) const
3181 return __pUserLoadingListener;
3185 IWebUiEventListener*
3186 _WebImpl::GetUiEventListener(void) const
3188 return __pUserUiListener;
3192 IWebUiEventListenerF*
3193 _WebImpl::GetUiEventListenerF(void) const
3195 return __pUserUiListenerF;
3199 IWebKeypadEventListener*
3200 _WebImpl::GetWebKeypadEventListener(void) const
3202 return __pUserKeypadEventListener;
3206 ITextSearchListener*
3207 _WebImpl::GetTextSearchListener(void) const
3209 return __pTextSearchListener;
3214 _WebImpl::SetEventListenerCallback(void) const
3216 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3219 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3220 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3222 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3223 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3225 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3226 SysAssertf(pSmartData, "Failed to request");
3228 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3229 SysAssertf(pSmart, "Failed to request");
3231 pSmart->popup_menu_show = OnSelectBoxRequested;
3232 pSmart->popup_menu_hide = OnSelectBoxClosed;
3233 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3235 pSmart->input_picker_show = OnDatePickerProviderRequested;
3236 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3237 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3239 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3241 // add loading event callbacks for ILoadingListener
3242 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3243 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3245 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3246 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3247 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3248 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3249 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3250 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3251 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3252 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3253 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3255 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3257 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3259 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3260 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3261 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3263 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3264 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3266 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3268 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3269 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3270 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3272 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3274 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3275 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3276 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3278 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3279 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3280 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3282 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3283 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3284 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3286 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3287 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3288 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3289 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3291 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3292 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3294 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3296 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3297 SysAssertf(pContext, "Failed to get webkit instance.");
3298 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3299 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3301 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3307 _WebImpl::RemoveEventListenerCallback(void) const
3309 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3312 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3313 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3315 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3316 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3318 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3319 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3321 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3322 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3323 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3324 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3325 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3326 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3327 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3328 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3330 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3332 evas_object_smart_callback_del(pWinObject, "focus,in", OnWindowObjectFocusGained);
3334 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3335 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3336 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3338 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3339 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3341 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3343 ewk_view_javascript_alert_callback_set(null, null, null);
3344 ewk_view_javascript_prompt_callback_set(null, null, null);
3345 ewk_view_javascript_confirm_callback_set(null, null, null);
3347 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3349 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3350 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3351 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3353 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3354 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3355 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3356 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3357 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3358 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3360 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3361 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3362 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3364 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3366 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3367 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3369 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3371 ewk_view_open_panel_callback_set(null, null, null);
3373 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3379 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3381 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3383 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3384 SysAssertf(pSmartData, "Failed to request");
3386 Point absPoint(__pWebCore->GetAbsoluteCoordinate(startPoint));
3388 pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3389 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3391 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3393 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3400 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3402 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToInteger(startPoint));
3407 _WebImpl::ReleaseBlock(void)
3409 ewk_view_command_execute(__pWebCore->GetWebNativeNode(), "Unselect", 0);
3414 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3416 FloatPoint tempStartPoint;
3417 FloatPoint tempEndPoint;
3419 GetBlockRange(tempStartPoint, tempEndPoint);
3421 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3422 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3427 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3429 Eina_Rectangle leftHandle;
3430 Eina_Rectangle rightHandle;
3432 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3434 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3435 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3436 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3437 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3439 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3441 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3442 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3448 _WebImpl::GetFaviconN(void) const
3450 result r = E_SUCCESS;
3452 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3454 Evas* pEvas = evas_object_evas_get(pView);
3455 Ewk_Context* pContext = ewk_view_context_get(pView);
3456 SysAssertf(pEvas && pContext, "Failed to request");
3458 const char* pUrl = ewk_view_url_get(pView);
3460 Tizen::Graphics::BufferInfo bufferInfo;
3461 Tizen::Base::ByteBuffer byteBuffer;
3463 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3464 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3466 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3472 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3473 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3475 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3477 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3478 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3480 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3481 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3483 return pBitmapImage.release();
3489 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3491 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3496 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3498 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3503 _WebImpl::GetScrollPosition(void) const
3507 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3514 _WebImpl::GetPageSize(void) const
3516 Evas_Coord width = 0;
3517 Evas_Coord height = 0;
3519 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3521 Dimension size(static_cast< int >(width), static_cast< int >(height));
3528 _WebImpl::SetLoadingErrorOccurred(bool arg)
3530 __isLoadingErrorOccurred = arg;
3535 _WebImpl::IsLoadingErrorOccurred(void) const
3537 return __isLoadingErrorOccurred;
3542 _WebImpl::SetRedirectRequested(bool arg)
3544 __isRedirectRequested = arg;
3549 _WebImpl::IsRedirectRequested(void) const
3551 return __isRedirectRequested;
3556 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3563 _WebImpl::GetPolicyDecision(void) const
3570 _WebImpl::SetCertificateRequested(bool arg)
3572 __isCertificateRequested = arg;
3577 _WebImpl::IsCertificateRequested(void) const
3579 return __isCertificateRequested;
3584 _WebImpl::IsCertificateConfirmed(void) const
3586 return __isCertificateConfirmed;
3591 _WebImpl::LaunchAppControl(const IEventArg& arg)
3593 result r = E_SUCCESS;
3595 IEventArg* pArg = const_cast< IEventArg* >(&arg);
3596 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
3597 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
3599 String operationId(L"");
3600 String uriPattern(pWebEventArg->GetEventMessage());
3601 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
3603 switch (pWebEventArg->GetEventType())
3605 case WEB_EVENT_REQUEST_RTSP:
3609 int uriLength = uriPattern.GetLength();
3612 operationId = L"http://tizen.org/appcontrol/operation/view";
3614 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
3615 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3617 r = uriPattern.SubString(index + 1, ext);
3618 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3620 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
3621 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3623 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
3624 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3628 case WEB_EVENT_REQUEST_TEL:
3630 operationId = L"http://tizen.org/appcontrol/operation/dial";
3633 case WEB_EVENT_REQUEST_EMAIL:
3635 case WEB_EVENT_REQUEST_SMS:
3637 case WEB_EVENT_REQUEST_MMS:
3639 operationId = L"http://tizen.org/appcontrol/operation/compose";
3642 case WEB_EVENT_REQUEST_UNKNOWN:
3644 operationId = L"http://tizen.org/appcontrol/operation/view";
3652 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
3653 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3660 _WebImpl::SetFullScreenKeypad(void)
3662 result r = E_SUCCESS;
3664 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3665 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3667 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3668 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3670 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3671 pKeypad->SetText(text);
3673 r = pKeypad->SetShowState(true);
3674 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3676 r = pKeypad->Show();
3677 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3679 pKeypad->AddTextEventListener(*this);
3681 __pKeypad = std::move(pKeypad);
3688 _WebImpl::RemoveFullScreenKeypad(void)
3690 __pKeypad->RemoveTextEventListener(*this);
3697 _WebImpl::IsFooterVisible(void) const
3699 return __isFooterVisible;
3704 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3706 __isFooterVisible = isFooterVisible;
3711 _WebImpl::IsKeypadVisible(void) const
3713 return __isKeypadVisible;
3718 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3720 __isKeypadVisible = isKeypadVisible;
3725 _WebImpl::IsKeypadOpened(void) const
3727 return __isKeypadOpened;
3731 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
3733 __isKeypadOpened = isKeypadOpened;
3738 _WebImpl::GetPreviousKeypadBounds(void) const
3740 return __keypadBounds;
3745 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
3747 __keypadBounds = bounds;
3752 _WebImpl::OnTextValueChangeCanceled(const Control& source)
3754 RemoveFullScreenKeypad();
3759 _WebImpl::OnTextValueChanged(const Control& source)
3761 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
3763 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
3765 RemoveFullScreenKeypad();
3770 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
3772 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
3773 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
3775 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
3776 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3778 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
3779 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
3781 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
3788 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
3790 result r = E_SUCCESS;
3792 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
3793 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3795 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3797 ILoadingListener* pLoadingListner = GetLoadingListener();
3798 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
3800 switch (pEventArg->GetEventType())
3802 case WEB_EVENT_LOADINGLISTENER_STARTED:
3804 pLoadingListner->OnLoadingStarted();
3808 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
3810 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
3811 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3813 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
3817 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
3819 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
3820 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3822 pLoadingListner->OnPageTitleReceived(*pPageTitle);
3826 case WEB_EVENT_LOADINGLISTENER_CANCELED:
3828 pLoadingListner->OnLoadingCanceled();
3832 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
3834 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
3835 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3837 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
3838 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3840 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
3842 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
3846 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
3848 pLoadingListner->OnLoadingCompleted();
3852 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
3854 pLoadingListner->OnHttpAuthenticationCanceled();
3858 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
3860 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
3861 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3865 pLoadingListner->OnFaviconReceived(*pFavicon.get());
3881 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
3883 result r = E_SUCCESS;
3885 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
3886 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3888 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3890 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
3891 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
3893 switch (pEventArg->GetEventType())
3895 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
3897 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
3898 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3900 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
3904 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
3906 pWebDownloadListener->OnWebDataDownloadCompleted();
3910 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
3912 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
3913 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3915 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
3917 pWebDownloadListener->OnWebDownloadFailed(errorType);
3932 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
3934 result r = E_SUCCESS;
3936 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
3937 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3939 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3941 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
3943 switch (pEventArg->GetEventType())
3945 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
3947 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3949 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
3950 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3952 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
3953 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3955 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
3959 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
3961 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3963 __pUserUiListener->OnWebPageShowRequested(*pWeb);
3967 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
3969 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3971 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
3975 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
3977 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3979 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
3980 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3982 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
3997 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
3999 result r = E_SUCCESS;
4001 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4002 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4004 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4006 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4008 switch (pEventArg->GetEventType())
4010 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4012 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4014 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4015 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4017 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4018 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4020 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4024 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4026 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4028 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4032 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4034 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4036 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4040 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4042 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4044 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4045 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4047 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4062 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4064 result r = E_SUCCESS;
4066 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4067 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4069 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4071 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4072 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4074 switch (pEventArg->GetEventType())
4076 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4078 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4079 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4081 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4082 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4084 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4099 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4101 result r = E_SUCCESS;
4103 String host(ewk_auth_challenge_url_get(pChallenge));
4104 String realm(ewk_auth_challenge_realm_get(pChallenge));
4106 __pAuthChallenge.reset();
4108 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4109 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4111 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4112 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4114 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4115 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4117 __pAuthChallenge = std::move(pAuthChallenge);
4119 ewk_auth_challenge_suspend(pChallenge);
4120 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4122 __pAuthChallenge.release();
4126 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4127 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4135 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4137 result r = E_SUCCESS;
4139 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4140 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4142 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4143 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4145 __pAuthPopup = std::move(pAuthPopup);
4147 int modalResult = 0;
4148 r = __pAuthPopup->ShowAndWait(modalResult);
4149 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4152 __pAuthPopup.reset();
4159 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4161 result r = E_SUCCESS;
4163 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4164 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4166 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4167 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4169 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4171 int modalResult = 0;
4172 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4173 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4175 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4177 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4181 __pCertConfirmPopup.reset();
4188 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy)
4190 result r = E_SUCCESS;
4192 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4193 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4195 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy);
4196 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4198 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4200 r = __pUserConfirmPopup->ShowPopup();
4201 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4203 __pUserConfirmPopup.release();
4208 __pUserConfirmPopup.reset();
4215 _WebImpl::GetParentFormCore(_Control* pControlCore)
4218 _Form* pFormCore = null;
4220 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4222 if (pParentControlCore == null)
4224 _Window* pWindowCore = dynamic_cast< _Window* >(pControlCore);
4225 SysAssertf(pWindowCore, "Failed to get parent control and window core.");
4226 pFormCore = dynamic_cast< _Form* >(pWindowCore->GetOwner());
4227 if (pFormCore == null)
4229 pParentControlCore = dynamic_cast< _Control* >(pWindowCore->GetOwner());
4230 SysTryReturn(NID_WEB_CTRL, pParentControlCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4235 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4238 if (pFormCore != null)
4243 return GetParentFormCore(pParentControlCore);
4248 _WebImpl::OnFocusGained(const _ControlImpl& source)
4255 _WebImpl::OnFocusLost(const _ControlImpl& source)
4257 if(IsKeypadVisible() == true)
4259 SetKeypadOpened(true);
4262 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4269 _WebImpl::HasValidNativeNode(void) const
4271 if (__pWebCore && __pWebCore->GetWebNativeNode())
4281 _WebImpl::OnAttachedToMainTree(void)
4283 result r = E_SUCCESS;
4285 r = __pWebCore->InitializeWebNativeNode();
4286 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4288 r = InitializeSetting();
4289 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4291 r = _ContainerImpl::OnAttachedToMainTree();
4292 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4299 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4301 _ContainerImpl::OnChangeLayout(orientation);
4303 if (IsKeypadVisible() == true)
4309 ecore_imf_context_input_panel_geometry_get(ecore_imf_context_add(ecore_imf_context_default_id_get()), &x, &y, &w, &h);
4311 _Form* pFormCore = GetParentFormCore(dynamic_cast< _Control* >(&this->GetCore()));
4312 SysAssertf(pFormCore != null, "Failed to get FormCore");
4314 pFormCore->DeflateClientRectHeight(h);
4317 if (__pColorPicker.get())
4319 __pColorPicker->ChangeLayout(orientation);
4325 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4327 if (IsVisible() == true)
4329 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4333 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4339 _WebImpl::GetDownloadHandler(void) const
4341 return __pWebDownloadHandler.get();
4346 _WebImpl::HideColorPicker(void)
4348 __pColorPicker.reset();
4355 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4357 result r = E_SUCCESS;
4359 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4360 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4362 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4364 r = pColorHadler->Construct(colorVal);
4365 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4367 __pColorPicker = std::move(pColorHadler);
4369 r = __pColorPicker->ShowPopup();
4370 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4372 color = __pColorPicker->GetColor();
4377 __pColorPicker.reset();
4384 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4386 result r = E_SUCCESS;
4388 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4389 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4391 r = pInputPicker->Construct(String(inputValue), inputType);
4392 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4394 __pDatePicker = std::move(pInputPicker);
4396 r = __pDatePicker->ShowPopup();
4397 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4399 dateStr = __pDatePicker->GetDate();
4402 __pDatePicker.reset();
4409 _WebImpl::GetInstance(Web* pWeb)
4411 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4416 _WebImpl::GetInstance(const Web* pWeb)
4418 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4422 }}} // Tizen::Web::Controls