2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_WebImpl.cpp
20 * @brief The file contains the definition of _WebImpl class.
22 * The file contains the definition of _WebImpl class.
24 #include <Ecore_IMF_Evas.h>
25 #include <Ecore_Evas.h>
26 #include <elm_config.h>
29 #include <ewk_popup_menu_item.h>
30 #include <libsoup/soup-status.h>
32 #include <FAppAppControl.h>
33 #include <FAppIAppControlListener.h>
34 #include <FBaseColAllElementsDeleter.h>
35 #include <FBaseColHashMapT.h>
36 #include <FBaseRtMutex.h>
37 #include <FBaseRtMutexGuard.h>
38 #include <FBaseSysLog.h>
39 #include <FBaseUtilUri.h>
40 #include <FCntDownloadRequest.h>
41 #include <FGrpColor.h>
42 #include <FGrpPoint.h>
43 #include <FGrpRectangle.h>
44 #include <FIoDbEnumerator.h>
45 #include <FIoDbStatement.h>
47 #include <FMediaImage.h>
48 #include <FMediaImageTypes.h>
49 #include <FNetHttpHttpHeader.h>
50 #include <FSysVibrator.h>
51 #include <FUiControl.h>
52 #include <FUiCtrlKeypad.h>
53 #include <FWebCtrlHitElementResult.h>
54 #include <FWebCtrlITextSearchListener.h>
55 #include <FWebCtrlIWebDownloadListener.h>
56 #include <FWebCtrlIWebUiEventListener.h>
57 #include <FWebCtrlIWebUiEventListenerF.h>
58 #include <FWebCtrlIWebKeypadEventListener.h>
59 #include <FWebCtrlIJavaScriptBridge.h>
60 #include <FWebCtrlPageNavigationList.h>
61 #include <FWebCtrlAuthenticationChallenge.h>
62 #include <FWebCtrlWeb.h>
63 #include <FWebCtrlWebSetting.h>
64 #include <FWebHistoryItem.h>
65 #include <FWebJsonJsonObject.h>
66 #include <FWebJsonJsonParser.h>
67 #include <FWebJsonJsonString.h>
68 #include <FApp_AppControlImpl.h>
69 #include <FApp_AppControlManager.h>
70 #include <FApp_AppInfo.h>
71 #include <FApp_AppManagerImpl.h>
72 #include <FBase_StringConverter.h>
73 #include <FCnt_DownloadManagerImpl.h>
74 #include <FCnt_ContentManagerImpl.h>
75 #include <FGrp_CoordinateSystem.h>
76 #include <FGrp_Screen.h>
77 #include <FIo_DatabaseImpl.h>
78 #include <FIo_NormalFile.h>
79 #include <FSys_VibratorImpl.h>
80 #include <FUi_Control.h>
81 #include <FUi_CoordinateSystemUtils.h>
82 #include <FUi_EcoreEvasMgr.h>
83 #include <FUi_EcoreEvas.h>
84 #include <FUi_ResourceSizeInfo.h>
85 #include <FUi_Window.h>
86 #include <FUiAnim_EflNode.h>
87 #include <FUiAnim_VisualElement.h>
88 #include <FUiCtrl_FooterImpl.h>
89 #include <FUiCtrl_Form.h>
90 #include "FWeb_HistoryItemImpl.h"
91 #include "FWebCtrl_AppControlListener.h"
92 #include "FWebCtrl_AuthConfirmPopup.h"
93 #include "FWebCtrl_AuthenticationChallengeImpl.h"
94 #include "FWebCtrl_EflWebkit.h"
95 #include "FWebCtrl_FormDataWindow.h"
96 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
97 #include "FWebCtrl_HitElementResultImpl.h"
98 #include "FWebCtrl_InputPickerPopup.h"
99 #include "FWebCtrl_WebNotification.h"
100 #include "FWebCtrl_PageNavigationListImpl.h"
101 #include "FWebCtrl_PromptPopup.h"
102 #include "FWebCtrl_SelectBox.h"
103 #include "FWebCtrl_Utility.h"
104 #include "FWebCtrl_Web.h"
105 #include "FWebCtrl_WebDataHandler.h"
106 #include "FWebCtrl_WebEvent.h"
107 #include "FWebCtrl_WebEventArg.h"
108 #include "FWebCtrl_WebImpl.h"
109 #include "FWebCtrl_WebPresenter.h"
110 #include "FWebCtrl_WebSettingImpl.h"
113 using namespace Tizen::App;
114 using namespace Tizen::Base;
115 using namespace Tizen::Base::Collection;
116 using namespace Tizen::Base::Runtime;
117 using namespace Tizen::Base::Utility;
118 using namespace Tizen::Content;
119 using namespace Tizen::Graphics;
120 using namespace Tizen::Io;
121 using namespace Tizen::Media;
122 using namespace Tizen::Net::Http;
123 using namespace Tizen::System;
124 using namespace Tizen::Ui;
125 using namespace Tizen::Ui::Animations;
126 using namespace Tizen::Ui::Controls;
127 using namespace Tizen::Web::Json;
130 namespace Tizen { namespace Web { namespace Controls
134 static const char WEB_CTRL[] = "webcontrol";
135 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
138 static const float MIN_ZOOM_LEVEL = 0.3;
139 static const float MAX_ZOOM_LEVEL = 2;
142 static const int REDIRECTION_HEADER_GROUP = 300;
145 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
148 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
149 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
150 static const int DEFAULT_LIST_ITEM_COUNT = 4;
154 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
156 result r = E_SUCCESS;
158 String key(reinterpret_cast< const char* >(pKey));
159 String value(reinterpret_cast< char* >(pValue));
161 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
163 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
164 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
171 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
173 result r = E_SUCCESS;
175 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
176 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
177 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
179 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
181 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
182 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
184 pAttrValue.release();
191 FreeCharArray(void* pData)
193 delete[] reinterpret_cast<char*>(pData);
198 ConvertErrorCode(int error)
200 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
204 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
206 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
208 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
210 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
212 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
214 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
216 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
218 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
220 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
222 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
224 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
226 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
228 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
230 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
231 errorCode = WEB_NO_CONNECTION;
234 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
236 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
237 errorCode = WEB_BAD_URL;
240 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
241 errorCode = WEB_FILE_ACCESS_FAILED;
244 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
245 errorCode = WEB_REQUEST_TIMEOUT;
248 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
249 errorCode = WEB_MIME_NOT_SUPPORTED;
252 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
253 errorCode = WEB_OUT_OF_MEMORY;
256 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
257 errorCode = WEB_REQUEST_MAX_EXCEEDED;
260 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
262 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
264 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
266 case EWK_ERROR_NETWORK_STATUS_OK:
268 case EWK_ERROR_NETWORK_STATUS_CREATED:
270 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
272 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
274 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
276 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
278 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
280 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
282 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
284 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
286 case EWK_ERROR_NETWORK_STATUS_FOUND:
288 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
290 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
292 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
294 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
296 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
297 errorCode = WEB_HTTP_RESPONSE;
300 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
301 errorCode = WEB_INVALID_CERTIFICATE;
305 errorCode = WEB_ERROR_UNKNOWN;
314 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
316 result r = E_SUCCESS;
318 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
319 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
320 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
321 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
323 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
324 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
325 pErrorCode.release();
327 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
328 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
329 pErrorDescription.release();
331 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
332 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
340 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
342 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
344 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
345 String msg(pMessage);
347 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
348 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
352 ewk_view_javascript_alert_reply(pView);
358 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
360 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
362 result r = E_SUCCESS;
363 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
364 String msg(pMessage);
366 MessageBox messageBox;
367 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
368 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
372 messageBox.SetOwner(&pImpl->GetPublic());
374 r = messageBox.ShowAndWait(modalResult);
375 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
377 if (modalResult == MSGBOX_RESULT_OK)
379 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
383 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
391 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
393 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
395 result r = E_SUCCESS;
396 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
398 String msg(pMessage);
399 String defVal(pDefaultValue);
401 r = pImpl->ShowPromptPopup(msg, defVal);
402 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
407 ewk_view_javascript_prompt_reply(pView, null);
414 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
416 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
417 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
418 SysAssertf(pImpl && pPolicy, "Failed to request");
420 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
422 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
424 if (pImpl->IsCertificateRequested())
426 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
430 result r = E_SUCCESS;
432 std::unique_ptr<DbEnumerator> pEnum;
434 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
435 String table(CERTIFICATE_TABLE_NAME);
438 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
440 r = db.Construct(certificatePath, "r", null);
441 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
443 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
446 r = pEnum->MoveNext();
447 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
450 r = pEnum->GetIntAt(0, allow);
451 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
453 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
455 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
456 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
460 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
461 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
464 pImpl->SetCertificateRequested(true);
467 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
468 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
470 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
471 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
480 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
481 pImpl->SetCertificateConfirmed(false);
482 pImpl->SetCertificateRequested(true);
487 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
489 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
490 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
491 SysAssertf(pImpl && pChallenge, "Failed to request");
493 result r = E_SUCCESS;
495 r = pImpl->HttpAuthenticationRequested(pChallenge);
496 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
500 ewk_auth_challenge_credential_cancel(pChallenge);
501 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
506 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
508 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
509 SysAssertf(pImpl , "Failed to request");
511 if (pImpl->GetLoadingListener())
513 result r = E_SUCCESS;
515 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
516 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
518 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
519 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
525 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
527 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
528 SysAssertf(pImpl , "Failed to request");
530 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
532 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
533 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
535 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
536 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
543 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
545 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
546 SysAssertf(pImpl , "Failed to request");
548 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
550 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
551 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
553 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
554 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
561 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
563 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
564 SysAssertf(pImpl , "Failed to request");
566 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
568 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
569 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
571 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
572 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
578 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
580 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
581 SysAssertf(pImpl , "Failed to request");
583 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
585 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
586 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
588 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
589 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
596 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
598 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
599 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
600 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
602 if (pImpl->GetSetting().IsGeolocationEnabled())
604 result r = E_SUCCESS;
606 std::unique_ptr<DbEnumerator> pEnum;
608 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
609 String table(GEOLOCATION_TABLE_NAME);
612 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
613 String origin = _Utility::CreateOrigin(pSecurityOrigin);
615 r = db.Construct(geolocationPath, "r", null);
616 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
618 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
621 r = pEnum->MoveNext();
622 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
625 r = pEnum->GetIntAt(0, permission);
626 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
628 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
630 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
634 ewk_geolocation_permission_request_suspend(pPermissionRequest);
636 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
637 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
644 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
649 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
651 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
652 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
653 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
655 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
656 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
660 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
665 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
667 result r = E_SUCCESS;
668 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
670 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
671 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
673 ewk_notification_permission_request_suspend(pPermissionRequest);
675 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
676 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
680 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
685 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
687 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
688 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
689 SysAssertf(pImpl && pNotification, "Failed to request");
691 result r = E_SUCCESS;
692 Ewk_Context* pContext = ewk_view_context_get(pView);
693 SysAssertf(pContext, "Failed to get webkit instance.");
694 uint64_t notificationId = ewk_notification_id_get(pNotification);
696 //ewk_notification_security_origin_get(pNotification)
698 const char* text = ewk_notification_body_get(pNotification);
699 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
701 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
702 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
704 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
705 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
707 pNotificationWindow->SetText(String(text));
708 pNotificationWindow->LaunchNotification();
709 pNotificationWindow.release();
711 ewk_notification_showed(pContext, notificationId);
716 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
718 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
719 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
720 SysAssertf(pImpl && pNotificationID, "Failed to request");
722 //ToDo : Where is ewk API for cancel operation?
727 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
729 result r = E_SUCCESS;
730 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
731 SysAssertf(pImpl, "Failed to request");
733 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
734 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
739 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
741 int checkHandler = 0;
742 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
743 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
744 SysAssertf(pImpl && pHandlerData, "Failed to request");
746 checkHandler = pImpl->SearchHandler(pHandlerData, false);
747 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
748 switch (checkHandler)
753 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
756 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
759 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
767 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
769 result r = E_SUCCESS;
770 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
771 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
772 SysAssertf(pImpl && pHandlerData, "Failed to request");
774 r = pImpl->UnregistrationHandler(pHandlerData, false);
775 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
780 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
782 result r = E_SUCCESS;
783 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
784 SysAssertf(pImpl, "Failed to request");
786 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
787 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
792 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
794 int checkHandler = 0;
795 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
796 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
797 SysAssertf(pImpl && pHandlerData, "Failed to request");
799 checkHandler = pImpl->SearchHandler(pHandlerData, true);
800 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
802 switch (checkHandler)
807 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
810 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
813 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
822 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
824 result r = E_SUCCESS;
825 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
826 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
827 SysAssertf(pImpl && pHandlerData, "Failed to request");
829 r = pImpl->UnregistrationHandler(pHandlerData, true);
830 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
835 OnVibrationRequested(uint64_t duration, void* pUserData)
837 result r = E_SUCCESS;
839 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
840 SysAssertf(pImpl, "Failed to request");
842 r = pImpl->VibrationRequested(duration);
843 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
848 OnVibrationCanceled(void* pUserData)
850 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
851 SysAssertf(pImpl, "Failed to request");
853 pImpl->VibrationCanceled();
858 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
860 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
861 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
862 SysAssertf(pImpl && pPolicy, "Failed to request");
864 String url(ewk_policy_decision_url_get(pPolicy));
865 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
867 if (url == L"about:blank")
869 ewk_policy_decision_use(pPolicy);
873 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
874 && !pImpl->IsRedirectRequested())
876 pImpl->SetCertificateRequested(false);
878 if (pImpl->GetTextSearchListener())
880 pImpl->DisableAsyncSearch();
883 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
884 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
886 switch (ewkNavigationType)
888 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
889 navigationType = WEB_NAVIGATION_LINK_CLICKED;
891 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
892 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
894 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
895 navigationType = WEB_NAVIGATION_BACKFORWARD;
897 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
898 navigationType = WEB_NAVIGATION_RELOAD;
900 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
901 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
903 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
904 navigationType = WEB_NAVIGATION_OTHER;
910 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
912 ewk_policy_decision_ignore(pPolicy);
918 String currentUrl(pImpl->GetUrl());
919 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
920 if (redirectUrl != L"")
922 pImpl->LoadUrl(redirectUrl);
923 ewk_policy_decision_ignore(pPolicy);
931 String uriScheme(uri.GetScheme());
932 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
934 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
936 ewk_policy_decision_ignore(pPolicy);
938 if (uriScheme == L"")
943 result r = E_SUCCESS;
945 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
947 if (uriScheme == L"rtsp")
949 eventType = WEB_EVENT_REQUEST_RTSP;
951 else if (uriScheme == L"mailto")
953 eventType = WEB_EVENT_REQUEST_EMAIL;
955 else if (uriScheme == L"tel")
957 eventType = WEB_EVENT_REQUEST_TEL;
959 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
961 eventType = WEB_EVENT_REQUEST_SMS;
963 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
965 eventType = WEB_EVENT_REQUEST_MMS;
968 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
969 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
971 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
972 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
978 ewk_policy_decision_use(pPolicy);
983 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
985 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
986 SysAssertf(pImpl, "Failed to request");
988 if (pImpl->GetLoadingListener())
990 result r = E_SUCCESS;
992 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
993 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
995 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
996 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1003 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1005 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1006 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1007 SysAssertf(pImpl, "Failed to request");
1009 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1011 if (pImpl->GetLoadingListener())
1013 result r = E_SUCCESS;
1015 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1016 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1017 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1019 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1020 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1021 pPageTitle.release();
1023 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1024 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1025 pEventArg.release();
1031 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1033 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1034 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1035 SysAssertf(pImpl, "Failed to request");
1037 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1039 if (pImpl->GetLoadingListener())
1041 result r = E_SUCCESS;
1043 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1044 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1045 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1047 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1048 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1049 pProgressPercentage.release();
1051 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1052 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1053 pEventArg.release();
1059 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1061 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1062 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1063 SysAssertf(pImpl && pPolicy, "Failed to request");
1065 result r = E_SUCCESS;
1067 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1068 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1069 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1070 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1072 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1074 String url(ewk_policy_decision_url_get(pPolicy));
1077 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1079 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1081 DecisionPolicy policy;
1082 HttpHeader httpHeader;
1084 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1086 pImpl->SetRedirectRequested(true);
1090 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1091 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1093 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1094 pImpl->SetPolicyDecision(policy);
1097 switch (pImpl->GetPolicyDecision())
1099 case WEB_DECISION_CONTINUE:
1101 String currentUrl(pImpl->GetUrl());
1102 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1103 if (redirectUrl != L"")
1105 pImpl->LoadUrl(redirectUrl);
1106 ewk_policy_decision_ignore(pPolicy);
1111 if (pImpl->IsMimeSupported(mime) || mime == L"")
1118 SysLog(NID_WEB_CTRL, "Launch native app to handle the mime");
1120 ewk_policy_decision_ignore(pPolicy);
1122 AppControl* pAppControl = null;
1123 _SelectBox selectBox;
1125 int selectedIndex = 0;
1127 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
1131 appCount = pList->GetCount();
1134 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
1135 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1137 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1138 for (int i = 0; i < appCount; i++)
1140 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
1141 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1143 String text = pAppControl->GetAppName();
1144 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
1146 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1148 r = selectBox.ShowAndWait(selectedIndex);
1149 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1151 if (selectedIndex == 0) //download
1153 RequestId reqId = 0;
1154 DownloadRequest request(pUrl);
1156 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1157 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1159 pManagerImpl->SetDownloadListener(pImpl);
1160 r = pManagerImpl->Start(request, reqId);
1161 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1163 else if (selectedIndex != -1) // -1 for cancel
1165 String path("path");
1166 String pathVal(pUrl);
1169 r = dataList.Construct();
1170 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1172 r = dataList.Add(path, pathVal);
1173 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1175 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
1176 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1178 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
1179 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1181 r = pAcImpl->Start(null, null, &dataList, null);
1182 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1189 case WEB_DECISION_DOWNLOAD:
1191 ewk_policy_decision_ignore(pPolicy);
1193 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1194 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1196 Ewk_Context* pContext = ewk_view_context_get(pView);
1197 SysAssertf(pContext, "Failed to get webkit instance.");
1199 pDownloadHandler->StartDownload(pUrl);
1203 case WEB_DECISION_IGNORE:
1205 ewk_policy_decision_ignore(pPolicy);
1215 ewk_policy_decision_use(pPolicy);
1220 ewk_policy_decision_ignore(pPolicy);
1225 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1227 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1228 SysAssertf(pImpl, "Failed to request");
1230 if (pImpl->IsRedirectRequested())
1232 pImpl->SetRedirectRequested(false);
1235 if (pImpl->IsLoadingErrorOccurred())
1237 pImpl->SetLoadingErrorOccurred(false);
1238 evas_object_smart_callback_call(pView, "load,finished", NULL);
1244 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1246 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1247 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1248 SysAssertf(pImpl && pErrorData, "Failed to request");
1250 int code = ewk_error_code_get(pErrorData);
1251 const char* pDescription = ewk_error_description_get(pErrorData);
1253 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1257 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1258 pImpl->SetLoadingErrorOccurred(true);
1261 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1262 evas_object_smart_callback_call(pView, "load,finished", NULL);
1265 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1266 pImpl->SetLoadingErrorOccurred(true);
1267 evas_object_smart_callback_call(pView, "load,stop", NULL);
1271 pImpl->SetLoadingErrorOccurred(true);
1272 if (pImpl->GetLoadingListener())
1274 result r = E_SUCCESS;
1276 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1277 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1285 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1287 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1288 SysAssertf(pImpl, "Failed to request");
1290 if (pImpl->GetLoadingListener())
1292 result r = E_SUCCESS;
1294 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1295 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1297 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1298 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1299 pEventArg.release();
1306 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1308 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1309 SysAssertf(pImpl, "Failed to request");
1311 if (pImpl->GetLoadingListener())
1313 result r = E_SUCCESS;
1315 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1316 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1318 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1319 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1320 pEventArg.release();
1327 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1329 evas_object_focus_set(pView, EINA_FALSE);
1334 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1336 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1337 SysAssertf(pImpl, "Failed to request");
1339 if (pImpl->GetLoadingListener())
1341 result r = E_SUCCESS;
1343 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1344 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1346 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1347 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1348 pEventArg.release();
1355 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1357 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1358 SysAssertf(pUrl && pImpl != null, "Failed to request");
1360 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1365 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1367 result r = E_SUCCESS;
1369 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1370 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1372 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1373 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1374 pEventArg.release();
1381 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1383 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1384 SysAssertf(pImpl, "Failed to request");
1386 if (pImpl->GetUiEventListener())
1388 result r = E_SUCCESS;
1390 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1391 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1393 if (pImpl->GetUiEventListenerF())
1395 result r = E_SUCCESS;
1397 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1398 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1404 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1406 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1407 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1408 SysAssertf(pParentImpl && pChildView, "Failed to request");
1410 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1411 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1412 if (pUserUiListener)
1414 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1417 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1418 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1420 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1421 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1424 if (pUserUiListenerF)
1426 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1429 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1430 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1432 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1433 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1440 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1442 result r = E_SUCCESS;
1444 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1445 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1447 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1448 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1449 pEventArg.release();
1456 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1458 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1459 SysAssertf(pChildImpl, "Failed to request");
1461 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1462 if (pParentImpl == null)
1467 if (pParentImpl->GetUiEventListener())
1469 result r = E_SUCCESS;
1471 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1472 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1474 if (pParentImpl->GetUiEventListenerF())
1476 result r = E_SUCCESS;
1478 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1479 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1485 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1487 result r = E_SUCCESS;
1489 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1490 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1491 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1493 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1494 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1495 pPreventTrigger.release();
1497 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1498 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1499 pEventArg.release();
1506 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1508 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1509 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1510 SysAssertf(pImpl && pTrigger, "Failed to request");
1512 if (pImpl->GetUiEventListener())
1514 result r = E_SUCCESS;
1516 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1517 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1519 if (pImpl->GetUiEventListenerF())
1521 result r = E_SUCCESS;
1523 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1524 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1530 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1532 result r = E_SUCCESS;
1534 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1535 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1536 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1538 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1540 if ((endPoint->x != 0) && (endPoint->y != 0))
1542 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1543 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1545 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1546 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1547 startPoint.release();
1549 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1550 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1553 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1554 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1555 pEventArg.release();
1563 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1565 result r = E_SUCCESS;
1567 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1568 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1570 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1572 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1574 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1576 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1577 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1579 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1580 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1581 startPoint.release();
1583 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1584 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1587 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1588 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1589 pEventArg.release();
1597 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1599 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1600 SysAssertf(pImpl, "Failed to request");
1602 if (pImpl->GetUiEventListener())
1604 result r = E_SUCCESS;
1606 r = FireWebPageBlockSelectedEvent(pImpl);
1607 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1609 if (pImpl->GetUiEventListenerF())
1611 result r = E_SUCCESS;
1613 r = FireWebPageBlockSelectedEventF(pImpl);
1614 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1620 OnWebPageBlockSelectedByOrientation(void* pUserData, Evas_Object* pView, void* pEventInfo)
1622 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1623 SysAssertf(pImpl, "Failed to request");
1625 if (!pImpl->IsOrientationChanged())
1630 pImpl->SetOrientationChanged(false);
1632 int orientation = 0;
1633 _ControlRotation rotation = _ControlManager::GetInstance()->GetOrientationStatus();
1636 case _CONTROL_ROTATION_0:
1639 case _CONTROL_ROTATION_90:
1642 case _CONTROL_ROTATION_180:
1645 case _CONTROL_ROTATION_270:
1649 ewk_view_orientation_send(pView, orientation);
1651 OnWebPageBlockSelected(pUserData, pView, pEventInfo);
1656 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1658 String isMultipleSelection(L"single");
1659 result r = E_SUCCESS;
1662 String mode(L"selectionType");
1663 String type(L"type");
1664 _AppControlImpl* pMediaAppControlImpl = null;
1667 String fileType = L"all";
1671 isMultipleSelection.Append(L"multiple");
1674 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1675 SysTryReturn(NID_WEB_CTRL, pMediaAppControl.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1677 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1678 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1680 pMediaListener->Construct(pView, pMediaAppControl.get());
1682 itemCount = eina_list_count(pAcceptTypes);
1686 String item((char*)eina_list_nth(pAcceptTypes, 0));
1687 if (item.StartsWith("image/",0))
1689 fileType = L"image";
1691 else if (item.StartsWith("audio/",0))
1693 fileType = L"audio";
1695 else if (item.StartsWith("video/",0))
1697 fileType = L"video";
1701 r = dataList.Construct();
1702 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1704 r = dataList.Add(mode, isMultipleSelection);
1705 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1707 r = dataList.Add(type, fileType);
1708 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1710 pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl.get());
1711 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1712 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1714 pMediaListener.release();
1715 pMediaAppControl.release();
1720 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1726 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1728 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1729 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1730 SysAssertf(pImpl && pJsonText, "Failed to request");
1732 result r = E_SUCCESS;
1734 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1736 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1737 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1739 r = pEventArg->Construct(pJsonText);
1740 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1742 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1743 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1744 pEventArg.release();
1749 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1751 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1752 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1753 SysAssertf(pImpl && pEinaRect, "Failed to request");
1755 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1757 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1758 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1760 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1762 if (rect.height == 0)
1767 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1770 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1772 pImpl->SetFooterVisibleState(true);
1773 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1776 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1779 if (pImpl->GetWebKeypadEventListener())
1781 if (pImpl->IsKeypadVisible() == true)
1783 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1785 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1790 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1793 pImpl->SetKeypadVisibleState(true);
1794 pImpl->SetPreviousKeypadBounds(rect);
1798 result r = pImpl->SetFullScreenKeypad();
1799 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1805 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1807 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1808 SysAssertf(pImpl, "Failed to request");
1810 if (pImpl->GetWebKeypadEventListener())
1812 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1818 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1820 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1821 SysAssertf(pImpl, "Failed to request");
1823 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1826 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1828 pImpl->SetFooterVisibleState(false);
1829 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1832 pFormCore->DeflateClientRectHeight(0);
1835 if (pImpl->GetWebKeypadEventListener())
1837 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1840 pImpl->SetKeypadVisibleState(false);
1845 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1847 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1848 SysAssertf(pImpl, "Failed to request");
1850 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true)
1852 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1853 SysAssertf(pWebCore, "Failed to get Web core object");
1855 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1858 pImpl->SetKeypadOpened(false);
1863 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1865 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1866 SysAssertf(pImpl, "Failed to request");
1868 if (pImpl->IsKeypadOpened() == true)
1870 pImpl->SetKeypadOpened(false);
1872 pImpl->SetFocused();
1878 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1880 SysAssertf(pSmartData, "invalid smartdata");
1881 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1882 SysAssertf(pWebImpl, "Failed to get Impl");
1884 result r = E_SUCCESS;
1886 if (pWebImpl->GetColorpicker())
1893 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1894 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1896 byte r1, g1, b1, a1;
1897 color.GetColorComponents(r1, g1, b1, a1);
1898 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1905 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1907 SysAssertf(pSmartData, "invalid smartdata");
1909 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1910 SysAssertf(pWebImpl, "Failed to get Impl");
1912 return pWebImpl->HideColorPicker();
1917 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1919 SysAssertf(pSmartData, "Failed to request");
1920 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1921 SysAssertf(pWebImpl, "Failed to get Impl");
1923 result r = E_SUCCESS;
1925 if (pWebImpl->GetDatepicker())
1927 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1934 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1935 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1937 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1938 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1940 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1947 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1949 SysAssertf(pSmartData, "Failed to request");
1951 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1952 SysAssertf(pWebImpl, "Failed to get Impl");
1954 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1955 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1962 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1964 SysAssertf(pSmartData, "Failed to request");
1966 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1967 SysAssertf(pWebImpl, "Failed to get Impl");
1969 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1970 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1977 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1979 SysAssertf(pSmartData, "invalid smartdata");
1981 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1982 SysAssertf(pWebImpl, "Failed to get Impl");
1984 result r = pWebImpl->ClearSelectBoxPopup();
1985 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1992 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1994 SysAssertf(pSmartData, "invalid smartdata");
1996 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1997 SysAssertf(pWebImpl, "Failed to get Impl");
1999 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
2000 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2007 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
2009 SysAssertf(pSmartData, "Failed to request");
2011 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2012 SysAssertf(pWebImpl, "Failed to get Impl");
2014 Rectangle windowRect(x, y, w, h);
2015 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
2016 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2023 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
2025 SysAssertf(pSmartData, "Failed to request");
2027 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2028 SysAssertf(pWebImpl, "Failed to get Impl");
2030 if (pWebImpl->IsFormDataWindowVisible())
2032 pWebImpl->HideFormDataWindow();
2040 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
2042 SysAssertf(pSmartData, "Failed to request");
2044 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2045 SysAssertf(pWebImpl, "Failed to get Impl");
2047 pWebImpl->SetFormDataList(pDataList);
2054 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
2056 SysAssertf(pSmartData, "Failed to request");
2058 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2059 SysAssertf(pWebImpl, "Failed to get Impl");
2061 if (pWebImpl->IsFormDataWindowVisible())
2073 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2075 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2076 SysAssertf(pPresenter && !pError, "Failed to request");
2078 bool ret = EINA_TRUE;
2082 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2084 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2088 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2097 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2099 pPresenter->EndAsyncProcess(ret);
2104 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2106 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2107 SysAssertf(pPresenter, "Failed to request");
2109 String result(pResult);
2110 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2112 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2113 if (pImpl && pImpl->IsPresenterAlived(pPresenter))
2115 pPresenter->EndAsyncProcess(result);
2121 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2123 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2124 SysAssertf(pImpl, "Failed to request");
2126 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2127 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2129 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2133 pWebPresenter->EndAsyncProcess(*pTotalCount);
2137 if (pImpl->GetTextSearchListener())
2139 result r = E_SUCCESS;
2143 if (*pTotalCount > 0)
2145 ordinal = pImpl->GetAsyncSearchOrdinal();
2146 pImpl->SetAsyncSearchResult(*pTotalCount);
2149 if (pImpl->GetPendingAsyncSearchCount() > 0)
2154 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2155 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2156 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2157 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2159 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2160 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2163 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2164 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2167 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2168 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2169 pEventArg.release();
2175 class _JsBridgeHashCodeProvider
2176 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2179 _JsBridgeHashCodeProvider(){}
2180 virtual ~_JsBridgeHashCodeProvider(void) {}
2183 int GetHashCode(const Tizen::Base::String& obj) const
2185 return obj.GetHashCode();
2191 //Comparer implementation
2192 class _JsBridgeComparer
2193 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2196 _JsBridgeComparer(){}
2197 virtual ~_JsBridgeComparer(void) {}
2200 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2217 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2218 : _ContainerImpl(pWeb, pCore)
2219 , __isFooterVisible(false)
2220 , __isKeypadVisible(false)
2221 , __isKeypadOpened(false)
2222 , __isLoadingErrorOccurred(false)
2223 , __isRedirectRequested(false)
2224 , __isCertificateRequested(false)
2225 , __isCertificateConfirmed(false)
2226 , __isOrientationChanged(false)
2227 , __isFormDataVisible(false)
2228 , __keypadBounds(0, 0, 0, 0)
2230 , __pUserLoadingListener(null)
2231 , __pUserUiListener(null)
2232 , __pUserUiListenerF(null)
2233 , __pUserKeypadEventListener(null)
2234 , __pTextSearchListener(null)
2236 , __pJsBridgeList(null)
2237 , __pJsProvider(null)
2238 , __pJsComparer(null)
2239 , __pWebDownloadHandler(null)
2241 , __pAuthChallenge(null)
2242 , __pAuthPopup(null)
2243 , __pUserConfirmPopup(null)
2244 , __pPromptPopup(null)
2245 , __pCertConfirmPopup(null)
2246 , __pSelectBox(null)
2247 , __pDatePicker(null)
2248 , __pColorPicker(null)
2249 , __pFormDataWindow(null)
2251 , __policy(WEB_DECISION_CONTINUE)
2252 , __defaultUserAgent(L"")
2253 , __pFormDataList(null)
2255 __textSearch.__searchAll = false;
2256 __textSearch.__searchForward = true;
2257 __textSearch.__caseSensitive = false;
2258 __textSearch.__pending = 0;
2259 __textSearch.__currentIndex = 1;
2260 __textSearch.__totalCount = -1;
2261 __textSearch.__text = L"";
2265 _WebImpl::~_WebImpl()
2267 RemoveEventListenerCallback();
2268 ClearCertificateDb();
2273 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2275 result r = E_SUCCESS;
2277 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2278 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2280 _Web* pCore = _Web::CreateWebN();
2281 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2283 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2285 r = CheckConstruction(pCore, pImpl);
2286 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2288 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2289 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2291 r = pImpl->Construct();
2292 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2304 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2306 result r = E_SUCCESS;
2308 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2309 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2311 _Web* pCore = _Web::CreateWebN();
2312 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2314 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2316 r = CheckConstruction(pCore, pImpl);
2317 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2319 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2320 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2322 r = pImpl->Construct();
2323 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2335 _WebImpl::Construct(void)
2337 result r = E_SUCCESS;
2339 r = __mutex.Create();
2340 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2342 r = __textSearch.__searchQueue.Construct();
2343 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2345 r = __callbackList.Construct();
2346 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2348 r = InitJsBridgeList();
2349 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2352 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2354 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2355 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2362 _WebImpl::InitializeSetting(void)
2364 result r = E_SUCCESS;
2366 WebSetting* pWebSetting = __pWebCore->GetSetting();
2367 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2369 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2370 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2372 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2374 r = SetSetting(*pWebSetting);
2375 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2377 SetEventListenerCallback();
2384 _WebImpl::IsLayoutable(void) const
2391 _WebImpl::InitWebEvent(void)
2393 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2394 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2396 return __pWebEvent->Construct(*this);
2401 _WebImpl::GetWebEvent(void) const
2403 return __pWebEvent.get();
2408 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2410 Eina_Hash* pHttpHeader = null;
2412 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2413 if (pFieldNameList.get())
2415 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2416 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2418 int count = pFieldNameList->GetCount();
2420 for (int i = 0; i < count; i++)
2422 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2423 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2425 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2426 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2428 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2429 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2431 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2433 Eina_Bool ret = false;
2435 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2436 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2438 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2439 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2441 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2442 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2449 eina_hash_free(pHttpHeader);
2456 _WebImpl::LoadUrl(const String& url) const
2458 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2459 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2461 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2468 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2470 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2471 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2473 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2475 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2477 eina_hash_free(pHttpHeader);
2484 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2486 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2487 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2489 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2491 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2493 eina_hash_free(pHttpHeader);
2500 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2502 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2504 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2505 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2506 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2507 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2509 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2516 _WebImpl::Pause(void)
2518 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2523 _WebImpl::Resume(void)
2525 ewk_view_resume(__pWebCore->GetWebNativeNode());
2530 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2532 __pSelectBox.reset();
2534 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2536 result r = E_SUCCESS;
2538 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2539 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2541 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2542 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2544 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2545 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2547 __pSelectBox = std::move(pSelectBox);
2549 __pSelectBox->SetOwner(&GetPublic());
2551 return __pSelectBox->ShowPopup();
2556 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2558 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2560 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2565 _WebImpl::ClearSelectBoxPopup(void)
2567 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2569 __pSelectBox.reset();
2576 _WebImpl::GetDatepicker(void)
2578 _InputPickerPopup* pInputPicker =null;
2581 pInputPicker = __pDatePicker.get();
2583 return pInputPicker;
2588 _WebImpl::GetColorpicker(void)
2590 _InputPickerPopup* pInputPicker =null;
2593 pInputPicker = __pColorPicker.get();
2595 return pInputPicker;
2600 _WebImpl::CanGoBack(void) const
2602 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2607 _WebImpl::CanGoForward(void) const
2609 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2614 _WebImpl::GoBack(void) const
2616 ewk_view_back(__pWebCore->GetWebNativeNode());
2621 _WebImpl::GoForward(void) const
2623 ewk_view_forward(__pWebCore->GetWebNativeNode());
2628 _WebImpl::GetUrl(void) const
2630 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2635 _WebImpl::GetTitle(void) const
2637 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2642 _WebImpl::StopLoading(void) const
2644 ewk_view_stop(__pWebCore->GetWebNativeNode());
2649 _WebImpl::Reload(void) const
2651 ewk_view_reload(__pWebCore->GetWebNativeNode());
2656 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2658 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2664 result r = E_SUCCESS;
2666 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2667 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2669 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
2670 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2672 r = __callbackList.Add(pPresenter.get());
2673 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2675 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2677 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2678 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2679 pPresenter->WaitAsyncProcess(*pResult.get());
2681 r = __callbackList.Remove(*pPresenter.get());
2682 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2683 pPresenter.release();
2685 return pResult.release();
2690 _WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
2692 return __callbackList.Contains(*pPresenter);
2697 _WebImpl::SetZoomLevel(float level)
2699 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);
2701 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2708 _WebImpl::GetZoomLevel(void) const
2710 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2714 const PageNavigationList*
2715 _WebImpl::GetBackForwardListN(void) const
2717 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2723 result r = E_SUCCESS;
2725 _PageNavigationListImpl* pNavigationListImpl = null;
2726 _HistoryItemImpl* pHistoryItemImpl = null;
2728 std::unique_ptr<PageNavigationList> pNavigationList;
2729 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2732 int forwardCount = 0;
2737 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2738 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2740 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2741 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2743 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2744 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2746 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2747 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2749 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2750 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2752 r = pHistoryList->Construct();
2753 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2755 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2756 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2757 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2759 for (int i = -backCount; i < forwardCount + 1; i++)
2761 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2762 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2764 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2765 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2767 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2768 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2770 url = ewk_history_item_uri_get(pEwkItem);
2771 title = ewk_history_item_title_get(pEwkItem);
2772 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2774 pHistoryItemImpl->SetHistoryItem(url, title);
2776 r = pHistoryList->Add(*pHistoryItem.get());
2777 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2778 pHistoryItem.release();
2781 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2783 ewk_history_free(pEwkHistoryList);
2785 return pNavigationList.release();
2788 ewk_history_free(pEwkHistoryList);
2795 _WebImpl::SearchText(const String& text, bool searchForward)
2797 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2803 result r = E_SUCCESS;
2805 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2809 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2812 _WebPresenter presenter;
2813 presenter.InitAsyncProcess();
2815 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, &presenter);
2816 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2819 presenter.WaitAsyncProcess(result);
2821 return static_cast < bool >(result);
2826 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2828 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2834 result r = E_SUCCESS;
2836 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2840 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2843 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2844 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2851 _WebImpl::SearchNextAsync(bool searchForward)
2853 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2859 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2860 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2861 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2863 result r = E_SUCCESS;
2865 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2867 if (!__textSearch.__caseSensitive)
2869 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2874 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2877 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2878 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2885 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2887 MutexGuard lock(__mutex);
2889 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2890 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2895 if (__textSearch.__searchAll)
2897 DisableAsyncSearch();
2899 __textSearch.__searchQueue.Enqueue(this);
2900 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2902 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2903 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2907 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2909 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2913 case SEARCH_ALL_ASYNC:
2914 __textSearch.__searchAll = true;
2915 __textSearch.__text = text;
2916 __textSearch.__searchForward = true;
2917 __textSearch.__caseSensitive = caseSensitive;
2918 __textSearch.__totalCount = -1;
2919 __textSearch.__currentIndex = 1;
2921 __textSearch.__searchQueue.Enqueue(this);
2922 __textSearch.__searchQueue.Enqueue(this);
2924 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2925 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2928 case SEARCH_NEXT_ASYNC:
2929 __textSearch.__searchForward = searchForward;
2931 CalculateAsyncSearchOrdinal();
2933 __textSearch.__searchQueue.Enqueue(this);
2935 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2947 _WebImpl::SetAsyncSearchResult(int totalCount)
2949 __textSearch.__totalCount = totalCount;
2954 _WebImpl::GetSearchPresenter(void)
2956 MutexGuard lock(__mutex);
2958 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2963 _WebImpl::GetPendingAsyncSearchCount(void) const
2965 return __textSearch.__searchQueue.GetCount();
2970 _WebImpl::CalculateAsyncSearchOrdinal(void)
2972 if (__textSearch.__searchForward)
2974 __textSearch.__currentIndex++;
2978 __textSearch.__currentIndex--;
2984 _WebImpl::GetAsyncSearchOrdinal(void) const
2986 return __textSearch.__currentIndex;
2991 _WebImpl::DisableAsyncSearch(void)
2993 __textSearch.__searchAll = false;
2998 _WebImpl::SetSetting(const WebSetting& setting)
3000 if (__pWebCore->GetWebNativeNode())
3002 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3003 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3004 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
3006 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
3007 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3009 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
3011 switch (setting.GetCacheControl())
3013 case WEB_CACHE_VALIDATED:
3014 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
3017 case WEB_CACHE_IGNORE:
3018 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
3025 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
3027 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
3031 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
3034 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
3036 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
3038 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
3040 if (__defaultUserAgent != setting.GetUserAgent())
3042 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
3043 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3045 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
3048 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
3050 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
3052 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3054 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3057 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3059 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3060 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3061 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3062 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3063 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3064 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3065 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3066 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3067 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3068 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3069 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3070 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3071 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3078 _WebImpl::GetSetting(void) const
3080 return *__pWebCore->GetSetting();
3084 const HitElementResult*
3085 _WebImpl::GetElementByPointN(const Point& point) const
3087 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3091 const HitElementResult*
3092 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3094 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3100 SysTryReturn(NID_WEB_CTRL, Contains(point), null, E_INVALID_ARG, "[%s] The point must be contained in the bounds of a web control.", GetErrorMessage(E_INVALID_ARG));
3102 result r = E_SUCCESS;
3104 _HitElementResultImpl* pHitElementResultImpl = null;
3106 std::unique_ptr<HitElementResult> pHitElementResult;
3107 std::unique_ptr<Bitmap> pImage;
3108 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3110 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3112 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3113 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3115 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3116 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3117 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3118 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3119 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3121 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3123 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3124 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3126 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3127 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3129 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3135 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3136 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3137 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3138 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3140 r = buf.Construct(imageLength);
3141 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3143 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3144 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3148 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3149 // webkit support types such as ico and vp8 additionally
3150 if (strcmp(pExtension, "gif") == 0)
3152 format = IMG_FORMAT_GIF;
3154 else if (strcmp(pExtension, "jpg") == 0)
3156 format = IMG_FORMAT_JPG;
3158 else if (strcmp(pExtension, "png") == 0)
3160 format = IMG_FORMAT_PNG;
3162 else if (strcmp(pExtension, "bmp") == 0)
3164 format = IMG_FORMAT_BMP;
3168 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3172 r = image.Construct();
3173 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3175 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3176 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3181 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3182 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3184 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3185 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3187 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3188 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3191 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3193 ewk_hit_test_free(pEwkHitTest);
3195 return pHitElementResult.release();
3198 ewk_hit_test_free(pEwkHitTest);
3205 _WebImpl::IsLoading(void) const
3207 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3209 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3221 _WebImpl::GetTextFromBlock(void) const
3223 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3228 _WebImpl::IsPrivateBrowsingEnabled(void) const
3230 if (__pWebCore->GetWebNativeNode() == null)
3232 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3235 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3236 SysAssertf(pSettings, "Failed to get webkit instance.");
3238 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3243 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3245 if (__pWebCore->GetWebNativeNode() == null)
3247 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3251 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3252 SysAssertf(pSettings, "Failed to get webkit instance.");
3254 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3259 _WebImpl::ClearHistory(void)
3261 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3266 _WebImpl::ClearCache(void)
3268 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3270 ewk_context_cache_clear(pContext);
3275 _WebImpl::ClearCookie(void)
3277 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3278 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3280 ewk_cookie_manager_cookies_clear(pCookieManager);
3285 _WebImpl::ClearFormData(void)
3287 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3289 ewk_context_form_candidate_data_clear(pContext);
3294 _WebImpl::ClearLoginFormData(void)
3296 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3298 ewk_context_form_password_data_clear(pContext);
3303 _WebImpl::IsCookieEnabled(void) const
3305 if (__pWebCore->GetWebNativeNode() == null)
3307 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3310 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3311 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3312 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3314 _WebPresenter presenter;
3315 presenter.InitAsyncProcess();
3317 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3319 bool result = false;
3320 presenter.WaitAsyncProcess(result);
3327 _WebImpl::SetCookieEnabled(bool enable)
3329 if (__pWebCore->GetWebNativeNode() == null)
3331 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3336 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3337 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3338 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3342 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3346 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3347 ewk_cookie_manager_cookies_clear(pCookieManager);
3353 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3355 result r = E_SUCCESS;
3357 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3358 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3361 String fileExtension = File::GetFileExtension(filePath);
3362 int pathLength = filePath.GetLength();
3365 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3367 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3368 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3369 r = filePath.SubString(0, index + 1, dirPath);
3370 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3372 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3373 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3377 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3379 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3383 Evas_Coord contentsWidth;
3384 Evas_Coord contentsHeight;
3386 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3387 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3395 _WebImpl::IsMimeSupported(const String& mime) const
3397 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3398 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3400 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3405 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3407 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3412 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3414 __pUserUiListener = pUiEventListener;
3419 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3421 __pUserUiListenerF = pUiEventListener;
3426 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3428 __pUserKeypadEventListener = pKeypadEventListener;
3433 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3435 if (__pWebDownloadHandler.get() == null)
3437 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3438 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3441 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3442 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3447 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3449 __pTextSearchListener = pTextSearchListener;
3454 _WebImpl::SetScrollEnabled(bool enable)
3456 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3461 _WebImpl::IsScrollEnabled(void) const
3463 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3468 _WebImpl::InitJsBridgeList(void)
3470 result r = E_SUCCESS;
3472 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3473 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3475 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3476 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3478 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3479 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3481 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3482 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3484 __pJsBridgeList = std::move(pJsBridgeList);
3491 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3493 result r = E_SUCCESS;
3495 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3496 String key(pJsBridge->GetName());
3498 r = __pJsBridgeList->Add(key, pJsBridge);
3499 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3506 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3508 result r = E_SUCCESS;
3510 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3511 String key(pJsBridge->GetName());
3513 r = __pJsBridgeList->Remove(key);
3514 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3521 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3523 result r = E_SUCCESS;
3525 IJsonValue* pJsonValue = null;
3526 IJavaScriptBridge* pJsBridge = null;
3528 String key(L"name");
3530 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3531 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));
3533 r = pJsonObject->GetValue(&key, pJsonValue);
3534 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3536 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3537 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3539 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3540 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3547 _WebImpl::GetLoadingListener(void) const
3549 return __pUserLoadingListener;
3553 IWebUiEventListener*
3554 _WebImpl::GetUiEventListener(void) const
3556 return __pUserUiListener;
3560 IWebUiEventListenerF*
3561 _WebImpl::GetUiEventListenerF(void) const
3563 return __pUserUiListenerF;
3567 IWebKeypadEventListener*
3568 _WebImpl::GetWebKeypadEventListener(void) const
3570 return __pUserKeypadEventListener;
3574 ITextSearchListener*
3575 _WebImpl::GetTextSearchListener(void) const
3577 return __pTextSearchListener;
3582 _WebImpl::SetEventListenerCallback(void) const
3584 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3587 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3588 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3590 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3591 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3593 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3594 SysAssertf(pSmartData, "Failed to request");
3596 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3597 SysAssertf(pSmart, "Failed to request");
3599 pSmart->popup_menu_show = OnSelectBoxRequested;
3600 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3601 pSmart->popup_menu_hide = OnSelectBoxClosed;
3602 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3604 pSmart->input_picker_show = OnDatePickerProviderRequested;
3605 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3606 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3608 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3609 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3610 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3611 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3613 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3615 // add loading event callbacks for ILoadingListener
3616 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3617 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3619 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3620 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3621 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3622 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3623 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3624 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3625 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3626 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3627 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3629 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3631 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3633 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3634 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3635 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3637 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3638 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3640 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3642 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3643 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3644 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3646 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3648 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3649 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3650 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3652 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3653 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3654 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3656 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3657 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3658 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3660 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3661 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3662 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3663 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3665 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3666 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3668 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3669 evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this);
3671 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3672 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3673 SysAssertf(pContext, "Failed to get webkit instance.");
3674 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3675 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3677 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3678 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3679 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3680 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3682 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3688 _WebImpl::RemoveEventListenerCallback(void) const
3690 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3693 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3694 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3696 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3697 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3699 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3700 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3702 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3703 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3704 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3705 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3706 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3707 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3708 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3709 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3711 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3713 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3715 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3716 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3717 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3719 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3720 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3722 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3724 ewk_view_javascript_alert_callback_set(null, null, null);
3725 ewk_view_javascript_prompt_callback_set(null, null, null);
3726 ewk_view_javascript_confirm_callback_set(null, null, null);
3728 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3730 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3731 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3732 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3734 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3735 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3736 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3737 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3738 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3739 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3741 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3742 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3743 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3745 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3747 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3748 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3750 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3751 evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation);
3753 ewk_view_open_panel_callback_set(null, null, null);
3754 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3755 SysAssertf(pContext, "Failed to get webkit instance.");
3756 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3758 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3759 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3760 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3761 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3763 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3769 _WebImpl::ClearCertificateDb(void)
3771 result r = E_SUCCESS;
3773 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3774 String table(CERTIFICATE_TABLE_NAME);
3777 r = db.Construct(certificatePath, "r+", null);
3778 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3780 db.BeginTransaction();
3782 r = db.ExecuteSql(L"Delete From " + table, true);
3783 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3785 db.CommitTransaction();
3790 db.RollbackTransaction();
3795 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3797 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3802 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3804 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3805 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
3806 if (pSmartData && pSmartData->api)
3808 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3810 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3813 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3815 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3816 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3818 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3820 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3822 ewk_view_command_execute(pView, "SelectWord", 0);
3826 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3827 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3830 ewk_view_command_execute(pView, "SelectWord", 0);
3836 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3843 _WebImpl::ReleaseBlock(void)
3845 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3850 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3852 FloatPoint tempStartPoint;
3853 FloatPoint tempEndPoint;
3855 GetBlockRange(tempStartPoint, tempEndPoint);
3857 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3858 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3863 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3865 Eina_Rectangle leftHandle;
3866 Eina_Rectangle rightHandle;
3868 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3869 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3871 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3873 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3874 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3875 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3876 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3878 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3880 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3881 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3887 _WebImpl::GetFaviconN(void) const
3889 result r = E_SUCCESS;
3891 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3892 Ewk_Context* pContext = ewk_view_context_get(pView);
3893 const char* pUrl = ewk_view_url_get(pView);
3894 Evas* pEvas = evas_object_evas_get(pView);
3896 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3902 Tizen::Graphics::BufferInfo bufferInfo;
3904 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3905 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3907 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3908 Tizen::Base::ByteBuffer byteBuffer;
3910 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3911 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3913 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3914 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3916 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3917 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3919 return pImage.release();
3925 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3927 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3932 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3934 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3939 _WebImpl::GetScrollPosition(void) const
3943 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3950 _WebImpl::GetPageSize(void) const
3952 Evas_Coord width = 0;
3953 Evas_Coord height = 0;
3955 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3957 Dimension size(static_cast< int >(width), static_cast< int >(height));
3964 _WebImpl::SetLoadingErrorOccurred(bool arg)
3966 __isLoadingErrorOccurred = arg;
3971 _WebImpl::IsLoadingErrorOccurred(void) const
3973 return __isLoadingErrorOccurred;
3978 _WebImpl::SetRedirectRequested(bool arg)
3980 __isRedirectRequested = arg;
3985 _WebImpl::IsRedirectRequested(void) const
3987 return __isRedirectRequested;
3992 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3999 _WebImpl::GetPolicyDecision(void) const
4006 _WebImpl::SetCertificateRequested(bool arg)
4008 __isCertificateRequested = arg;
4013 _WebImpl::IsCertificateRequested(void) const
4015 return __isCertificateRequested;
4020 _WebImpl::SetCertificateConfirmed(bool arg)
4022 __isCertificateConfirmed = arg;
4027 _WebImpl::IsCertificateConfirmed(void) const
4029 return __isCertificateConfirmed;
4034 _WebImpl::SetOrientationChanged(bool arg)
4036 __isOrientationChanged = arg;
4041 _WebImpl::IsOrientationChanged(void) const
4043 return __isOrientationChanged;
4048 _WebImpl::LaunchAppControl(const IEventArg& arg)
4050 result r = E_SUCCESS;
4052 IEventArg* pArg = const_cast< IEventArg* >(&arg);
4053 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
4054 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
4056 String operationId(L"");
4057 String uriPattern(pWebEventArg->GetEventMessage());
4058 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
4060 switch (pWebEventArg->GetEventType())
4062 case WEB_EVENT_REQUEST_RTSP:
4066 int uriLength = uriPattern.GetLength();
4069 operationId = L"http://tizen.org/appcontrol/operation/view";
4071 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
4072 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4074 r = uriPattern.SubString(index + 1, ext);
4075 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4077 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
4078 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4080 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
4081 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4085 case WEB_EVENT_REQUEST_TEL:
4087 operationId = L"http://tizen.org/appcontrol/operation/dial";
4090 case WEB_EVENT_REQUEST_EMAIL:
4092 case WEB_EVENT_REQUEST_SMS:
4094 case WEB_EVENT_REQUEST_MMS:
4096 operationId = L"http://tizen.org/appcontrol/operation/compose";
4099 case WEB_EVENT_REQUEST_UNKNOWN:
4101 operationId = L"http://tizen.org/appcontrol/operation/view";
4109 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
4110 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4117 _WebImpl::SetFullScreenKeypad(void)
4119 result r = E_SUCCESS;
4121 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4122 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4124 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4125 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4127 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4128 pKeypad->SetText(text);
4130 r = pKeypad->SetShowState(true);
4131 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4133 r = pKeypad->Show();
4134 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4136 pKeypad->AddTextEventListener(*this);
4138 __pKeypad = std::move(pKeypad);
4145 _WebImpl::RemoveFullScreenKeypad(void)
4147 __pKeypad->RemoveTextEventListener(*this);
4154 _WebImpl::IsFooterVisible(void) const
4156 return __isFooterVisible;
4161 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4163 __isFooterVisible = isFooterVisible;
4168 _WebImpl::IsKeypadVisible(void) const
4170 return __isKeypadVisible;
4175 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4177 __isKeypadVisible = isKeypadVisible;
4182 _WebImpl::IsKeypadOpened(void) const
4184 return __isKeypadOpened;
4188 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4190 __isKeypadOpened = isKeypadOpened;
4195 _WebImpl::GetPreviousKeypadBounds(void) const
4197 return __keypadBounds;
4202 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4204 __keypadBounds = bounds;
4209 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4211 RemoveFullScreenKeypad();
4216 _WebImpl::OnTextValueChanged(const Control& source)
4218 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4220 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4222 RemoveFullScreenKeypad();
4227 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4229 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4230 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4232 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4233 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4235 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4236 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4238 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4245 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4247 result r = E_SUCCESS;
4249 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4250 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4252 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4254 ILoadingListener* pLoadingListner = GetLoadingListener();
4255 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4257 switch (pEventArg->GetEventType())
4259 case WEB_EVENT_LOADINGLISTENER_STARTED:
4261 pLoadingListner->OnLoadingStarted();
4265 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4267 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4268 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4270 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4274 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4276 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4277 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4279 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4283 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4285 pLoadingListner->OnLoadingCanceled();
4289 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4291 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4292 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4294 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4295 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4297 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4299 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4303 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4305 pLoadingListner->OnLoadingCompleted();
4309 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4311 pLoadingListner->OnHttpAuthenticationCanceled();
4315 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4317 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4318 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4322 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4338 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4340 result r = E_SUCCESS;
4342 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4343 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4345 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4347 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4348 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4350 switch (pEventArg->GetEventType())
4352 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4354 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4355 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4357 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4361 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4363 pWebDownloadListener->OnWebDataDownloadCompleted();
4367 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4369 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4370 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4372 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4374 pWebDownloadListener->OnWebDownloadFailed(errorType);
4389 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4391 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4392 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4394 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4396 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4398 switch (pEventArg->GetEventType())
4400 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4402 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4404 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4405 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4407 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4408 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4410 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4414 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4416 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4418 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4422 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4424 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4426 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4430 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4432 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4434 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4435 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4437 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4452 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4454 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4455 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4457 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4459 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4461 switch (pEventArg->GetEventType())
4463 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4465 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4467 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4468 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4470 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4471 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4473 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4477 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4479 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4481 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4485 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4487 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4489 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4493 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4495 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4497 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4498 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4500 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4515 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4517 result r = E_SUCCESS;
4519 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4520 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4522 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4524 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4525 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4527 switch (pEventArg->GetEventType())
4529 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4531 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4532 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4534 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4535 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4537 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4552 _WebImpl::VibrationRequested(uint64_t duration)
4554 result r = E_SUCCESS;
4556 __pVibrator.reset();
4558 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4559 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4561 r = pVibrator->Construct();
4562 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4564 __pVibrator = std::move(pVibrator);
4566 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4568 r = __pVibrator->Start(&pattern, 1, 1);
4569 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4576 _WebImpl::VibrationCanceled(void)
4578 __pVibrator.reset();
4583 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4585 result r = E_SUCCESS;
4587 String host(ewk_auth_challenge_url_get(pChallenge));
4588 String realm(ewk_auth_challenge_realm_get(pChallenge));
4590 __pAuthChallenge.reset();
4592 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4593 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4595 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4596 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4598 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4599 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4601 __pAuthChallenge = std::move(pAuthChallenge);
4603 ewk_auth_challenge_suspend(pChallenge);
4604 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4606 __pAuthChallenge.release();
4610 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4611 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4619 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4621 result r = E_SUCCESS;
4623 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4624 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4626 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4627 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4629 __pAuthPopup = std::move(pAuthPopup);
4631 int modalResult = 0;
4633 __pAuthPopup->SetOwner(&GetPublic());
4635 r = __pAuthPopup->ShowAndWait(modalResult);
4636 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4639 __pAuthPopup.reset();
4646 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4648 result r = E_SUCCESS;
4650 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4651 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4653 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4654 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4656 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4658 int modalResult = 0;
4660 __pCertConfirmPopup->SetOwner(&GetPublic());
4662 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4663 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4665 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4667 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4671 __pCertConfirmPopup.reset();
4678 _WebImpl::ShowPromptPopup(String msg, String defVal)
4680 result r = E_SUCCESS;
4682 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4683 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4685 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode());
4686 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4688 __pPromptPopup = std::move(pPromptPopup);
4690 __pPromptPopup->SetOwner(&GetPublic());
4692 r = __pPromptPopup->ShowPopup();
4693 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4698 __pPromptPopup.reset();
4706 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4708 result r = E_SUCCESS;
4710 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4711 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4713 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
4714 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4716 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4718 int modalResult = 0;
4720 __pUserConfirmPopup->SetOwner(&GetPublic());
4722 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4723 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4726 __pUserConfirmPopup.reset();
4733 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4735 result r = E_SUCCESS;
4737 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4738 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4740 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
4741 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4743 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4745 __pUserConfirmPopup->SetOwner(&GetPublic());
4747 r = __pUserConfirmPopup->ShowPopup();
4748 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4750 __pUserConfirmPopup.release();
4755 __pUserConfirmPopup.reset();
4762 _WebImpl::GetParentFormCore(_Control* pControlCore)
4765 _Form* pFormCore = null;
4767 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4768 if (!pParentControlCore)
4773 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4779 return GetParentFormCore(pParentControlCore);
4784 _WebImpl::OnFocusGained(const _ControlImpl& source)
4791 _WebImpl::OnFocusLost(const _ControlImpl& source)
4793 if(IsKeypadVisible() == true)
4795 SetKeypadOpened(true);
4797 SetKeypadVisibleState(false);
4800 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4807 _WebImpl::HasValidNativeNode(void) const
4809 if (__pWebCore && __pWebCore->GetWebNativeNode())
4819 _WebImpl::OnPreAttachedToMainTree(void)
4821 result r = E_SUCCESS;
4823 r = __pWebCore->InitializeWebNativeNode();
4824 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4826 r = InitializeSetting();
4827 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4829 r = _ContainerImpl::OnPreAttachedToMainTree();
4830 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4837 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4839 _ContainerImpl::OnChangeLayout(orientation);
4841 if (__pColorPicker.get())
4843 __pColorPicker->ChangeLayout(orientation);
4846 HideFormDataWindow();
4848 __isOrientationChanged = true;
4853 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4855 if (IsVisible() == true)
4857 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4861 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4867 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4871 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4872 __pCertConfirmPopup.reset();
4874 case ID_PROMPT_POPUP_CLOSE:
4875 __pPromptPopup.reset();
4877 case ID_USER_CONFIRM_POPUP_CLOSE:
4878 __pUserConfirmPopup.reset();
4887 _WebImpl::GetDownloadHandler(void) const
4889 return __pWebDownloadHandler.get();
4894 _WebImpl::HideColorPicker(void)
4896 __pColorPicker.reset();
4903 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4905 result r = E_SUCCESS;
4907 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4908 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4910 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4912 r = pColorHadler->Construct(colorVal, this);
4913 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4915 __pColorPicker = std::move(pColorHadler);
4917 r = __pColorPicker->ShowPopup();
4918 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4920 color = __pColorPicker->GetColor();
4925 __pColorPicker.reset();
4932 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4934 result r = E_SUCCESS;
4936 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4937 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4939 r = pInputPicker->Construct(String(inputValue), inputType, this);
4940 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4942 __pDatePicker = std::move(pInputPicker);
4944 r = __pDatePicker->ShowPopup();
4945 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4947 dateStr = __pDatePicker->GetDate();
4950 __pDatePicker.reset();
4957 _WebImpl::GetInstance(Web* pWeb)
4959 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4964 _WebImpl::GetInstance(const Web* pWeb)
4966 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4971 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4973 int checkReturn = 0;
4975 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4978 if( checkmime == true)
4980 table = CUSTOM_CONTENT_TABLE_NAME;
4984 table = CUSTOM_PROTOCOL_TABLE_NAME;
4987 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4988 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4989 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4991 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4993 result r = db.Construct(handlerPath, "r+", null);
4994 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4996 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
4997 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5001 r = pEnum->MoveNext();
5002 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5003 r = pEnum->GetIntAt(0, checkReturn);
5004 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5016 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5020 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5023 if( checkmime == true)
5025 table = CUSTOM_CONTENT_TABLE_NAME;
5029 table = CUSTOM_PROTOCOL_TABLE_NAME;
5032 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5033 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5034 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5036 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5038 result r = db.Construct(handlerPath, "r+", null);
5039 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5041 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select id From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
5042 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5046 r = pEnum->MoveNext();
5047 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5048 r = pEnum->GetIntAt(0, checkId);
5049 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5051 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5052 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5054 r = pDeleteStmt->BindInt(0, checkId);
5055 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5057 db.BeginTransaction();
5059 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5061 db.CommitTransaction();
5068 const Tizen::Base::String
5069 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5071 if (originUri == L"" || currentUri == L"")
5076 result r = E_SUCCESS;
5079 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5080 String originReplace(originUri);
5081 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5085 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5086 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5088 r = currentUri.SubString(0, found + 1, baseUri);
5089 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5091 r = db.Construct(handlerPath, "r+", null);
5092 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5094 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5095 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5099 while (pEnum->MoveNext() == E_SUCCESS)
5104 String originScheme;
5106 r = pEnum->GetStringAt(0, protocol);
5107 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5109 r = pEnum->GetStringAt(1, queryUrl);
5110 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5112 r = pEnum->GetIntAt(2, allow);
5113 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5120 String protocolScheme(protocol + L":");
5122 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5123 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5125 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5127 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5129 r = originReplace.Replace(originScheme, "");
5130 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5132 queryUrl.Replace("%s", originReplace, 0);
5133 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5145 const Tizen::Base::String
5146 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5148 if (originUri == L"" || currentUri == L"" || mime == L"")
5153 result r = E_SUCCESS;
5156 String originUrlStr = originUri;
5157 const String replaceStr = L"%s";
5159 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5160 String table(CUSTOM_CONTENT_TABLE_NAME);
5164 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5165 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5167 r = currentUri.SubString(0, found + 1, baseUri);
5168 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5170 r = db.Construct(handlerPath, "r+", null);
5171 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5173 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5177 r = pEnum->MoveNext();
5178 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5179 r = pEnum->GetIntAt(0, allow);
5180 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5181 r = pEnum->GetStringAt(1, contentUrl);
5182 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5190 if (contentUrl != L"")
5192 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5193 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5205 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5207 __pFormDataList = pFormDataList;
5212 _WebImpl::IsFormDataWindowVisible(void) const
5214 return __isFormDataVisible;
5219 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5221 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5223 if (__isFormDataVisible)
5225 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5226 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5230 __pFormDataWindow.reset();
5232 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5233 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5235 result r = pFormDataWindow->Construct(rect, this, pWebView);
5236 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5238 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5239 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5241 r = pFormDataWindow->LaunchFormDataWindow();
5242 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5244 __pFormDataWindow = std::move(pFormDataWindow);
5245 __isFormDataVisible = true;
5253 _WebImpl::HideFormDataWindow(bool delWindow)
5257 __pFormDataWindow.reset();
5260 __isFormDataVisible = false;
5265 _WebImpl::OnDownloadCompleted(RequestId reqId, const String &path)
5267 _ContentManagerImpl::ScanFile(path);
5271 }}} // Tizen::Web::Controls