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_SystemResource.h>
80 #include <FSys_VibratorImpl.h>
81 #include <FUi_Control.h>
82 #include <FUi_CoordinateSystemUtils.h>
83 #include <FUi_EcoreEvasMgr.h>
84 #include <FUi_EcoreEvas.h>
85 #include <FUi_ResourceSizeInfo.h>
86 #include <FUi_Window.h>
87 #include <FUiAnim_EflNode.h>
88 #include <FUiAnim_VisualElement.h>
89 #include <FUiCtrl_FooterImpl.h>
90 #include <FUiCtrl_Form.h>
91 #include "FWeb_HistoryItemImpl.h"
92 #include "FWebCtrl_AppControlListener.h"
93 #include "FWebCtrl_AuthConfirmPopup.h"
94 #include "FWebCtrl_AuthenticationChallengeImpl.h"
95 #include "FWebCtrl_EflWebkit.h"
96 #include "FWebCtrl_FormDataWindow.h"
97 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
98 #include "FWebCtrl_HitElementResultImpl.h"
99 #include "FWebCtrl_InputPickerPopup.h"
100 #include "FWebCtrl_WebNotification.h"
101 #include "FWebCtrl_PageNavigationListImpl.h"
102 #include "FWebCtrl_PromptPopup.h"
103 #include "FWebCtrl_SelectBox.h"
104 #include "FWebCtrl_Utility.h"
105 #include "FWebCtrl_Web.h"
106 #include "FWebCtrl_WebDataHandler.h"
107 #include "FWebCtrl_WebEvent.h"
108 #include "FWebCtrl_WebEventArg.h"
109 #include "FWebCtrl_WebImpl.h"
110 #include "FWebCtrl_WebManager.h"
111 #include "FWebCtrl_WebPresenter.h"
112 #include "FWebCtrl_WebSettingImpl.h"
115 using namespace Tizen::App;
116 using namespace Tizen::Base;
117 using namespace Tizen::Base::Collection;
118 using namespace Tizen::Base::Runtime;
119 using namespace Tizen::Base::Utility;
120 using namespace Tizen::Content;
121 using namespace Tizen::Graphics;
122 using namespace Tizen::Io;
123 using namespace Tizen::Media;
124 using namespace Tizen::Net::Http;
125 using namespace Tizen::System;
126 using namespace Tizen::Ui;
127 using namespace Tizen::Ui::Animations;
128 using namespace Tizen::Ui::Controls;
129 using namespace Tizen::Web::Json;
132 namespace Tizen { namespace Web { namespace Controls
136 static const char WEB_CTRL[] = "webcontrol";
137 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
140 static const float MIN_ZOOM_LEVEL = 0.3;
141 static const float MAX_ZOOM_LEVEL = 2;
144 static const int REDIRECTION_HEADER_GROUP = 300;
147 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
150 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
151 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
152 static const int DEFAULT_LIST_ITEM_COUNT = 4;
156 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
158 result r = E_SUCCESS;
160 String key(reinterpret_cast< const char* >(pKey));
161 String value(reinterpret_cast< char* >(pValue));
163 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
165 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
166 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
173 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
175 result r = E_SUCCESS;
177 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
178 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
179 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
181 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
183 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
184 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
186 pAttrValue.release();
193 FreeCharArray(void* pData)
195 delete[] reinterpret_cast<char*>(pData);
200 ConvertErrorCode(int error)
202 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
206 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
208 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
210 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
212 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
214 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
216 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
218 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
220 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
222 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
224 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
226 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
228 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
230 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
232 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
233 errorCode = WEB_NO_CONNECTION;
236 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
238 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
239 errorCode = WEB_BAD_URL;
242 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
243 errorCode = WEB_FILE_ACCESS_FAILED;
246 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
247 errorCode = WEB_REQUEST_TIMEOUT;
250 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
251 errorCode = WEB_MIME_NOT_SUPPORTED;
254 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
255 errorCode = WEB_OUT_OF_MEMORY;
258 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
259 errorCode = WEB_REQUEST_MAX_EXCEEDED;
262 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
264 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
266 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
268 case EWK_ERROR_NETWORK_STATUS_OK:
270 case EWK_ERROR_NETWORK_STATUS_CREATED:
272 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
274 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
276 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
278 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
280 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
282 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
284 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
286 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
288 case EWK_ERROR_NETWORK_STATUS_FOUND:
290 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
292 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
294 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
296 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
298 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
299 errorCode = WEB_HTTP_RESPONSE;
302 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
303 errorCode = WEB_INVALID_CERTIFICATE;
307 errorCode = WEB_ERROR_UNKNOWN;
316 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
318 result r = E_SUCCESS;
320 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
321 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
322 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
323 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
325 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
326 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
327 pErrorCode.release();
329 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
330 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
331 pErrorDescription.release();
333 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
334 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
342 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
344 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
346 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
347 String msg(pMessage);
349 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
350 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
354 ewk_view_javascript_alert_reply(pView);
360 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
362 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
364 result r = E_SUCCESS;
365 String msg(pMessage);
367 MessageBox messageBox;
368 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
369 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
373 r = messageBox.ShowAndWait(modalResult);
374 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
376 if (modalResult == MSGBOX_RESULT_OK)
378 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
382 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
390 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
392 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
394 result r = E_SUCCESS;
395 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
397 String msg(pMessage);
398 String defVal(pDefaultValue);
400 r = pImpl->ShowPromptPopup(msg, defVal);
401 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
406 ewk_view_javascript_prompt_reply(pView, null);
413 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
415 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
416 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
417 SysAssertf(pImpl && pPolicy, "Failed to request");
419 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
421 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
423 if (pImpl->IsCertificateRequested())
425 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
429 result r = E_SUCCESS;
431 std::unique_ptr<DbEnumerator> pEnum;
433 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
434 String table(CERTIFICATE_TABLE_NAME);
437 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
439 r = db.Construct(certificatePath, "r", null);
440 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
442 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
445 r = pEnum->MoveNext();
446 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
449 r = pEnum->GetIntAt(0, allow);
450 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
452 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
454 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
455 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
459 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
460 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
465 pImpl->SetCertificateRequested(true);
469 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
470 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
472 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
473 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
482 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
483 pImpl->SetCertificateConfirmed(false);
484 pImpl->SetCertificateRequested(true);
489 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
491 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
492 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
493 SysAssertf(pImpl && pChallenge, "Failed to request");
495 result r = E_SUCCESS;
497 r = pImpl->HttpAuthenticationRequested(pChallenge);
498 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
502 ewk_auth_challenge_credential_cancel(pChallenge);
503 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
508 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
510 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
511 SysAssertf(pImpl , "Failed to request");
513 if (pImpl->GetLoadingListener())
515 result r = E_SUCCESS;
517 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
518 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
520 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
521 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
527 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
529 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
530 SysAssertf(pImpl , "Failed to request");
532 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
534 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
535 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
537 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
538 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
545 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
547 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
548 SysAssertf(pImpl , "Failed to request");
550 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
552 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
553 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
555 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
556 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
563 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
565 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
566 SysAssertf(pImpl , "Failed to request");
568 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
570 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
571 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
573 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
574 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
580 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
582 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
583 SysAssertf(pImpl , "Failed to request");
585 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
587 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
588 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
590 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
591 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
598 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
600 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
601 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
602 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
604 if (pImpl->GetSetting().IsGeolocationEnabled())
606 result r = E_SUCCESS;
608 std::unique_ptr<DbEnumerator> pEnum;
610 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
611 String table(GEOLOCATION_TABLE_NAME);
614 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
615 String origin = _Utility::CreateOrigin(pSecurityOrigin);
617 r = db.Construct(geolocationPath, "r", null);
618 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
620 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
623 r = pEnum->MoveNext();
624 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
627 r = pEnum->GetIntAt(0, permission);
628 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
630 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
632 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
636 ewk_geolocation_permission_request_suspend(pPermissionRequest);
638 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
639 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
646 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
651 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
653 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
654 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
655 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
657 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
658 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
662 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
667 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
669 result r = E_SUCCESS;
670 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
672 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
673 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
675 ewk_notification_permission_request_suspend(pPermissionRequest);
677 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
678 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
682 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
687 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
689 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
690 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
691 SysAssertf(pImpl && pNotification, "Failed to request");
693 result r = E_SUCCESS;
694 Ewk_Context* pContext = ewk_view_context_get(pView);
695 SysAssertf(pContext, "Failed to get webkit instance.");
696 uint64_t notificationId = ewk_notification_id_get(pNotification);
698 //ewk_notification_security_origin_get(pNotification)
700 const char* text = ewk_notification_body_get(pNotification);
701 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
703 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
704 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
706 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
707 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
709 pNotificationWindow->SetText(String(text));
710 pNotificationWindow->LaunchNotification();
711 pImpl->SetWebNotification(pNotificationWindow.release());
713 ewk_notification_showed(pContext, notificationId);
718 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
720 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
721 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
722 SysAssertf(pImpl && pNotificationID, "Failed to request");
724 //ToDo : Where is ewk API for cancel operation?
729 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
731 result r = E_SUCCESS;
732 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
733 SysAssertf(pImpl, "Failed to request");
735 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
736 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
741 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
743 int checkHandler = 0;
744 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
745 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
746 SysAssertf(pImpl && pHandlerData, "Failed to request");
748 checkHandler = pImpl->SearchHandler(pHandlerData, false);
749 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
750 switch (checkHandler)
755 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
758 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
761 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
769 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
771 result r = E_SUCCESS;
772 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
773 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
774 SysAssertf(pImpl && pHandlerData, "Failed to request");
776 r = pImpl->UnregistrationHandler(pHandlerData, false);
777 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
782 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
784 result r = E_SUCCESS;
785 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
786 SysAssertf(pImpl, "Failed to request");
788 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
789 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
794 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
796 int checkHandler = 0;
797 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
798 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
799 SysAssertf(pImpl && pHandlerData, "Failed to request");
801 checkHandler = pImpl->SearchHandler(pHandlerData, true);
802 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
804 switch (checkHandler)
809 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
812 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
815 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
824 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
826 result r = E_SUCCESS;
827 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
828 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
829 SysAssertf(pImpl && pHandlerData, "Failed to request");
831 r = pImpl->UnregistrationHandler(pHandlerData, true);
832 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
837 OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo)
839 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
840 SysAssertf(pImpl, "Failed to request");
842 SysLog(NID_WEB_CTRL, "Enter.");
847 OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
849 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
850 SysAssertf(pImpl, "Failed to request");
852 SysLog(NID_WEB_CTRL, "Exit.");
857 OnVibrationRequested(uint64_t duration, void* pUserData)
859 result r = E_SUCCESS;
861 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
862 SysAssertf(pImpl, "Failed to request");
864 r = pImpl->VibrationRequested(duration);
865 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
870 OnVibrationCanceled(void* pUserData)
872 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
873 SysAssertf(pImpl, "Failed to request");
875 pImpl->VibrationCanceled();
880 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
882 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
883 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
884 SysAssertf(pImpl && pPolicy, "Failed to request");
886 String url(ewk_policy_decision_url_get(pPolicy));
887 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
889 if (url == L"about:blank")
891 ewk_policy_decision_use(pPolicy);
895 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
896 && !pImpl->IsRedirectRequested())
898 pImpl->SetCertificateRequested(false);
900 if (pImpl->GetTextSearchListener())
902 pImpl->DisableAsyncSearch();
905 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
906 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
908 switch (ewkNavigationType)
910 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
911 navigationType = WEB_NAVIGATION_LINK_CLICKED;
913 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
914 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
916 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
917 navigationType = WEB_NAVIGATION_BACKFORWARD;
919 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
920 navigationType = WEB_NAVIGATION_RELOAD;
922 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
923 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
925 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
926 navigationType = WEB_NAVIGATION_OTHER;
932 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
934 ewk_policy_decision_ignore(pPolicy);
940 String currentUrl(pImpl->GetUrl());
941 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
942 if (redirectUrl != L"")
944 pImpl->LoadUrl(redirectUrl);
945 ewk_policy_decision_ignore(pPolicy);
953 String uriScheme(uri.GetScheme());
954 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
956 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
958 ewk_policy_decision_ignore(pPolicy);
960 if (uriScheme == L"")
965 result r = E_SUCCESS;
967 if (uriScheme == L"tel")
969 String operationId(L"http://tizen.org/appcontrol/operation/dial");
970 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
972 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
974 String operationId(L"http://tizen.org/appcontrol/operation/compose");
975 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
979 String operationId(L"http://tizen.org/appcontrol/operation/view");
980 String mime(ewk_policy_decision_response_mime_get(pPolicy));
981 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
983 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
988 ewk_policy_decision_use(pPolicy);
993 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
995 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
996 SysAssertf(pImpl, "Failed to request");
998 if (pImpl->GetLoadingListener())
1000 result r = E_SUCCESS;
1002 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
1003 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1005 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1006 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1007 pEventArg.release();
1013 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1015 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1016 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1017 SysAssertf(pImpl, "Failed to request");
1019 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1021 if (pImpl->GetLoadingListener())
1023 result r = E_SUCCESS;
1025 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1026 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1027 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1029 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1030 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1031 pPageTitle.release();
1033 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1034 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1035 pEventArg.release();
1041 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1043 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1044 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1045 SysAssertf(pImpl, "Failed to request");
1047 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1049 if (pImpl->GetLoadingListener())
1051 result r = E_SUCCESS;
1053 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1054 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1055 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1057 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1058 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1059 pProgressPercentage.release();
1061 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1062 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1063 pEventArg.release();
1069 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1071 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1072 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1073 SysAssertf(pImpl && pPolicy, "Failed to request");
1075 result r = E_SUCCESS;
1077 _SystemResource* pSysResource = _SystemResource::GetInstance();
1078 SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
1080 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1081 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1082 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1083 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1085 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1087 String url(ewk_policy_decision_url_get(pPolicy));
1089 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1091 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1093 DecisionPolicy policy;
1094 HttpHeader httpHeader;
1096 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1098 pImpl->SetRedirectRequested(true);
1102 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1103 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1105 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1106 pImpl->SetPolicyDecision(policy);
1109 switch (pImpl->GetPolicyDecision())
1111 case WEB_DECISION_CONTINUE:
1113 String currentUrl(pImpl->GetUrl());
1114 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1115 if (redirectUrl != L"")
1117 pImpl->LoadUrl(redirectUrl);
1118 ewk_policy_decision_ignore(pPolicy);
1123 if (pImpl->IsMimeSupported(mime) || mime == L"")
1130 ewk_policy_decision_ignore(pPolicy);
1132 String operationId(L"http://tizen.org/appcontrol/operation/view");
1134 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1135 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1137 if (r == E_OBJ_NOT_FOUND)
1139 _SelectBox* pSelectBox = new (std::nothrow) _SelectBox;
1140 SysTryReturnVoidResult(NID_WEB_CTRL, pSelectBox, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1142 r = pSelectBox->Construct(false, L"Select application", 1, null, url);
1143 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1145 pSelectBox->AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1146 r = pSelectBox->ShowPopup();
1147 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1154 case WEB_DECISION_DOWNLOAD:
1156 ewk_policy_decision_ignore(pPolicy);
1158 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1159 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1161 Ewk_Context* pContext = ewk_view_context_get(pView);
1162 SysAssertf(pContext, "Failed to get webkit instance.");
1164 pDownloadHandler->StartDownload(pUrl);
1168 case WEB_DECISION_IGNORE:
1170 ewk_policy_decision_ignore(pPolicy);
1180 ewk_policy_decision_use(pPolicy);
1185 ewk_policy_decision_ignore(pPolicy);
1190 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1192 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1193 SysAssertf(pImpl, "Failed to request");
1195 if (pImpl->IsRedirectRequested())
1197 pImpl->SetRedirectRequested(false);
1200 if (pImpl->IsLoadingErrorOccurred())
1202 pImpl->SetLoadingErrorOccurred(false);
1203 evas_object_smart_callback_call(pView, "load,finished", NULL);
1209 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1211 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1212 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1213 SysAssertf(pImpl && pErrorData, "Failed to request");
1215 int code = ewk_error_code_get(pErrorData);
1216 const char* pDescription = ewk_error_description_get(pErrorData);
1218 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1222 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1223 pImpl->SetLoadingErrorOccurred(true);
1226 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1227 evas_object_smart_callback_call(pView, "load,finished", NULL);
1230 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1231 pImpl->SetLoadingErrorOccurred(true);
1232 evas_object_smart_callback_call(pView, "load,stop", NULL);
1236 pImpl->SetLoadingErrorOccurred(true);
1237 if (pImpl->GetLoadingListener())
1239 result r = E_SUCCESS;
1241 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1242 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1250 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1252 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1253 SysAssertf(pImpl, "Failed to request");
1255 if (pImpl->GetLoadingListener())
1257 result r = E_SUCCESS;
1259 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1260 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1262 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1263 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1264 pEventArg.release();
1271 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1273 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1274 SysAssertf(pImpl, "Failed to request");
1276 if (pImpl->GetLoadingListener())
1278 result r = E_SUCCESS;
1280 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1281 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1283 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1284 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1285 pEventArg.release();
1292 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1294 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1295 SysAssertf(pImpl, "Failed to request");
1297 if (pImpl->GetLoadingListener())
1299 result r = E_SUCCESS;
1301 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1302 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1304 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1305 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1306 pEventArg.release();
1313 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1315 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1316 SysAssertf(pUrl && pImpl != null, "Failed to request");
1318 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1323 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1325 result r = E_SUCCESS;
1327 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1328 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1330 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1331 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1332 pEventArg.release();
1339 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1341 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1342 SysAssertf(pImpl, "Failed to request");
1344 if (pImpl->GetUiEventListener())
1346 result r = E_SUCCESS;
1348 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1349 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1351 if (pImpl->GetUiEventListenerF())
1353 result r = E_SUCCESS;
1355 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1356 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1362 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1364 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1365 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1366 SysAssertf(pParentImpl && pChildView, "Failed to request");
1368 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1369 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1370 if (pUserUiListener)
1372 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1375 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1376 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1378 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1379 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1382 if (pUserUiListenerF)
1384 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1387 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1388 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1390 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1391 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1398 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1400 result r = E_SUCCESS;
1402 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1403 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1405 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1406 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1407 pEventArg.release();
1414 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1416 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1417 SysAssertf(pChildImpl, "Failed to request");
1419 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1420 if (pParentImpl == null)
1425 if (pParentImpl->GetUiEventListener())
1427 result r = E_SUCCESS;
1429 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1430 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1432 if (pParentImpl->GetUiEventListenerF())
1434 result r = E_SUCCESS;
1436 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1437 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1443 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1445 result r = E_SUCCESS;
1447 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1448 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1449 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1451 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1452 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1453 pPreventTrigger.release();
1455 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1456 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1457 pEventArg.release();
1464 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1466 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1467 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1468 SysAssertf(pImpl && pTrigger, "Failed to request");
1470 if (pImpl->GetUiEventListener())
1472 result r = E_SUCCESS;
1474 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1475 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1477 if (pImpl->GetUiEventListenerF())
1479 result r = E_SUCCESS;
1481 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1482 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1488 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1490 result r = E_SUCCESS;
1492 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1493 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1494 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1496 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1498 if ((endPoint->x != 0) && (endPoint->y != 0))
1500 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1501 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1503 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1504 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1505 startPoint.release();
1507 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1508 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1511 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1512 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1513 pEventArg.release();
1521 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1523 result r = E_SUCCESS;
1525 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1526 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1528 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1530 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1532 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1534 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1535 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1537 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1538 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1539 startPoint.release();
1541 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1542 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1545 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1546 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1547 pEventArg.release();
1555 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1557 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1558 SysAssertf(pImpl, "Failed to request");
1560 if (pImpl->GetUiEventListener())
1562 result r = E_SUCCESS;
1564 r = FireWebPageBlockSelectedEvent(pImpl);
1565 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1567 if (pImpl->GetUiEventListenerF())
1569 result r = E_SUCCESS;
1571 r = FireWebPageBlockSelectedEventF(pImpl);
1572 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1578 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1580 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1581 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1583 pMediaListener->Construct(pView);
1586 result r = extraData.Construct();
1587 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_TRUE, r, "[%s] Propagating.", GetErrorMessage(r));
1589 String isMultipleSelection(L"single");
1590 String mode(L"selectionType");
1591 String type(L"type");
1592 String fileType = L"*/*";
1593 String operationId = L"http://tizen.org/appcontrol/operation/pick";
1597 isMultipleSelection.Append(L"multiple");
1600 if (eina_list_count(pAcceptTypes) == 1)
1602 String item((char*)eina_list_nth(pAcceptTypes, 0));
1603 String captureString(pCapture);
1605 if (item.StartsWith("image/",0))
1607 if (captureString == L"camera")
1609 fileType = L"image/jpg";
1610 operationId = L"http://tizen.org/appcontrol/operation/create_content";
1611 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
1612 String typeVal = L"false";
1613 extraData.Add(&typeKey, &typeVal);
1617 fileType = L"image/*";
1618 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1619 extraData.Add(&selectKey, &isMultipleSelection);
1622 else if (item.StartsWith("audio/",0))
1624 fileType = L"audio/*";
1625 //TO DO: as microphone is not supported yet. suggest to throw an exception
1626 //if (captureString == L"microphone")
1628 //operationId = L"http://tizen.org/appcontrol/operation/create_content";
1632 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1633 extraData.Add(&selectKey, &isMultipleSelection);
1636 else if (item.StartsWith("video/",0))
1638 if (captureString == L"camcorder")
1640 fileType = L"video/3gpp";
1641 operationId = L"http://tizen.org/appcontrol/operation/create_content";
1642 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
1643 String typeVal = L"false";
1644 extraData.Add(&typeKey, &typeVal);
1648 fileType = L"video/*";
1649 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1650 extraData.Add(&selectKey, &isMultipleSelection);
1655 r = _AppControlImpl::FindAndStart(operationId, null, &fileType, null, &extraData, pMediaListener.get());
1656 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1658 pMediaListener.release();
1663 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1669 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1671 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1672 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1673 SysAssertf(pImpl && pJsonText, "Failed to request");
1675 result r = E_SUCCESS;
1677 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1679 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1680 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1682 r = pEventArg->Construct(pJsonText);
1683 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1685 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1686 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1687 pEventArg.release();
1692 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1694 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1695 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1696 SysAssertf(pImpl && pEinaRect, "Failed to request");
1698 if (pImpl->IsVisible() == false)
1700 evas_object_focus_set(pView, EINA_FALSE);
1703 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1705 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1706 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1708 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1710 if (rect.height == 0)
1715 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1718 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1720 if (pFormCore->HasFooter())
1722 pFormCore->SetKeypadShowState(true);
1727 if (pImpl->GetWebKeypadEventListener())
1729 if (pImpl->IsKeypadVisible() == true)
1731 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1733 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1738 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1741 pImpl->SetKeypadVisibleState(true);
1742 pImpl->SetPreviousKeypadBounds(rect);
1746 result r = pImpl->SetFullScreenKeypad();
1747 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1753 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1755 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1756 SysAssertf(pImpl, "Failed to request");
1758 if (pImpl->GetWebKeypadEventListener())
1760 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1766 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1768 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1769 SysAssertf(pImpl, "Failed to request");
1771 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1774 pFormCore->DeflateClientRectHeight(0);
1776 if (pFormCore->HasFooter())
1778 pFormCore->SetKeypadShowState(false);
1783 if (pImpl->GetWebKeypadEventListener())
1785 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1788 pImpl->SetKeypadVisibleState(false);
1793 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1795 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1796 SysAssertf(pImpl, "Failed to request");
1798 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true && pImpl->IsFocused() == true)
1800 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1801 SysAssertf(pWebCore, "Failed to get Web core object");
1803 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1805 pImpl->SetKeypadVisibleState(true);
1811 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1813 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1814 SysAssertf(pImpl, "Failed to request");
1816 if (pImpl->IsKeypadOpened() == true)
1818 pImpl->SetKeypadOpened(false);
1824 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1826 SysAssertf(pSmartData, "invalid smartdata");
1827 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1828 SysAssertf(pWebImpl, "Failed to get Impl");
1830 result r = E_SUCCESS;
1832 if (pWebImpl->GetColorpicker())
1839 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1840 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1842 byte r1, g1, b1, a1;
1843 color.GetColorComponents(r1, g1, b1, a1);
1844 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1851 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1853 SysAssertf(pSmartData, "invalid smartdata");
1855 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1856 SysAssertf(pWebImpl, "Failed to get Impl");
1858 return pWebImpl->HideColorPicker();
1863 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1865 SysAssertf(pSmartData, "Failed to request");
1866 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1867 SysAssertf(pWebImpl, "Failed to get Impl");
1869 result r = E_SUCCESS;
1871 if (pWebImpl->GetDatepicker())
1873 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1880 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1881 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1883 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1884 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1886 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1893 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1895 SysAssertf(pSmartData, "Failed to request");
1897 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1898 SysAssertf(pWebImpl, "Failed to get Impl");
1900 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1901 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1908 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1910 SysAssertf(pSmartData, "Failed to request");
1912 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1913 SysAssertf(pWebImpl, "Failed to get Impl");
1915 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1916 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1923 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1925 SysAssertf(pSmartData, "invalid smartdata");
1927 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1928 SysAssertf(pWebImpl, "Failed to get Impl");
1930 result r = pWebImpl->ClearSelectBoxPopup();
1931 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1938 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1940 SysAssertf(pSmartData, "invalid smartdata");
1942 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1943 SysAssertf(pWebImpl, "Failed to get Impl");
1945 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1946 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1953 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1955 SysAssertf(pSmartData, "Failed to request");
1957 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1958 SysAssertf(pWebImpl, "Failed to get Impl");
1960 Rectangle windowRect(x, y, w, h);
1961 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1962 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1969 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
1971 SysAssertf(pSmartData, "Failed to request");
1973 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1974 SysAssertf(pWebImpl, "Failed to get Impl");
1976 if (pWebImpl->IsFormDataWindowVisible())
1978 pWebImpl->HideFormDataWindow();
1986 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
1988 SysAssertf(pSmartData, "Failed to request");
1990 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1991 SysAssertf(pWebImpl, "Failed to get Impl");
1993 pWebImpl->SetFormDataList(pDataList);
2000 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
2002 SysAssertf(pSmartData, "Failed to request");
2004 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2005 SysAssertf(pWebImpl, "Failed to get Impl");
2007 if (pWebImpl->IsFormDataWindowVisible())
2019 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2021 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2022 SysAssertf(pPresenter && !pError, "Failed to request");
2024 bool ret = EINA_TRUE;
2028 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2030 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2034 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2043 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2045 pPresenter->EndAsyncProcess(ret);
2050 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2052 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2053 SysAssertf(pPresenter, "Failed to request");
2055 String result(pResult);
2056 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2058 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2059 _WebManager* pWebManager = _WebManager::GetInstance();
2060 if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
2062 pPresenter->EndAsyncProcess(result);
2068 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2070 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2071 SysAssertf(pImpl, "Failed to request");
2073 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2074 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2076 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2080 pWebPresenter->EndAsyncProcess(*pTotalCount);
2084 if (pImpl->GetTextSearchListener())
2086 result r = E_SUCCESS;
2090 if (*pTotalCount > 0)
2092 ordinal = pImpl->GetAsyncSearchOrdinal();
2093 pImpl->SetAsyncSearchResult(*pTotalCount);
2096 if (pImpl->GetPendingAsyncSearchCount() > 0)
2101 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2102 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2103 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2104 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2106 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2107 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2110 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2111 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2114 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2115 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2116 pEventArg.release();
2122 class _JsBridgeHashCodeProvider
2123 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2126 _JsBridgeHashCodeProvider(){}
2127 virtual ~_JsBridgeHashCodeProvider(void) {}
2130 int GetHashCode(const Tizen::Base::String& obj) const
2132 return obj.GetHashCode();
2138 //Comparer implementation
2139 class _JsBridgeComparer
2140 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2143 _JsBridgeComparer(){}
2144 virtual ~_JsBridgeComparer(void) {}
2147 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2164 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2165 : _ContainerImpl(pWeb, pCore)
2166 , __isFooterVisible(false)
2167 , __isKeypadVisible(false)
2168 , __isKeypadOpened(false)
2169 , __isLoadingErrorOccurred(false)
2170 , __isRedirectRequested(false)
2171 , __isCertificateRequested(false)
2172 , __isCertificateConfirmed(false)
2173 , __isFormDataVisible(false)
2174 , __keypadBounds(0, 0, 0, 0)
2176 , __pUserLoadingListener(null)
2177 , __pUserUiListener(null)
2178 , __pUserUiListenerF(null)
2179 , __pUserKeypadEventListener(null)
2180 , __pTextSearchListener(null)
2182 , __pJsBridgeList(null)
2183 , __pJsProvider(null)
2184 , __pJsComparer(null)
2185 , __pWebDownloadHandler(null)
2187 , __pAuthChallenge(null)
2188 , __pAuthPopup(null)
2189 , __pUserMediaConfirmPopup(null)
2190 , __pContentHandlerConfirmPopup(null)
2191 , __pProtocolHandlerConfirmPopup(null)
2192 , __pGeolocationConfirmPopup(null)
2193 , __pNotificationConfirmPopup(null)
2194 , __pScriptAlertConfirmPopup(null)
2195 , __pAppCacheConfirmPopup(null)
2196 , __pDbQuotaConfirmPopup(null)
2197 , __pLocalFsQuotaConfirmPopup(null)
2198 , __pIndexedDbQuotaConfirmPopup(null)
2199 , __pPromptPopup(null)
2200 , __pCertConfirmPopup(null)
2201 , __pSelectBox(null)
2202 , __pDatePicker(null)
2203 , __pColorPicker(null)
2204 , __pFormDataWindow(null)
2206 , __policy(WEB_DECISION_CONTINUE)
2207 , __defaultUserAgent(L"")
2208 , __pFormDataList(null)
2210 __textSearch.__searchAll = false;
2211 __textSearch.__searchForward = true;
2212 __textSearch.__caseSensitive = false;
2213 __textSearch.__pending = 0;
2214 __textSearch.__currentIndex = 1;
2215 __textSearch.__totalCount = -1;
2216 __textSearch.__text = L"";
2220 _WebImpl::~_WebImpl()
2222 _WebManager* pWebManager = _WebManager::GetInstance();
2223 pWebManager->RemoveWeb(reinterpret_cast< int >(this));
2225 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2226 pManagerImpl->SetDownloadListener(null);
2228 RemoveEventListenerCallback();
2229 ClearCertificateDb();
2234 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2236 result r = E_SUCCESS;
2238 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2239 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2241 _Web* pCore = _Web::CreateWebN();
2242 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2244 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2246 r = CheckConstruction(pCore, pImpl);
2247 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2249 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2250 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2252 r = pImpl->Construct();
2253 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2265 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2267 result r = E_SUCCESS;
2269 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2270 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2272 _Web* pCore = _Web::CreateWebN();
2273 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2275 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2277 r = CheckConstruction(pCore, pImpl);
2278 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2280 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2281 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2283 r = pImpl->Construct();
2284 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2296 _WebImpl::Construct(void)
2298 result r = E_SUCCESS;
2300 r = __mutex.Create();
2301 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2303 r = __textSearch.__searchQueue.Construct();
2304 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2306 r = __webNotificationList.Construct();
2307 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2309 r = InitJsBridgeList();
2310 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2313 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2315 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2316 SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2318 pManagerImpl->SetDownloadListener(this);
2320 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2321 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2323 _WebManager* pWebManager = _WebManager::GetInstance();
2324 pWebManager->AddWeb(reinterpret_cast< int >(this));
2331 _WebImpl::InitializeSetting(void)
2333 result r = E_SUCCESS;
2335 WebSetting* pWebSetting = __pWebCore->GetSetting();
2336 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2338 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2339 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2341 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2343 r = SetSetting(*pWebSetting);
2344 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2346 SetEventListenerCallback();
2353 _WebImpl::IsLayoutable(void) const
2360 _WebImpl::InitWebEvent(void)
2362 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2363 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2365 return __pWebEvent->Construct(*this);
2370 _WebImpl::GetWebEvent(void) const
2372 return __pWebEvent.get();
2377 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2379 Eina_Hash* pHttpHeader = null;
2381 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2382 if (pFieldNameList.get())
2384 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2385 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2387 int count = pFieldNameList->GetCount();
2389 for (int i = 0; i < count; i++)
2391 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2392 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2394 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2395 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2397 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2398 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2400 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2402 Eina_Bool ret = false;
2404 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2405 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2407 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2408 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2410 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2411 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2418 eina_hash_free(pHttpHeader);
2425 _WebImpl::LoadUrl(const String& url) const
2427 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2428 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2430 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2437 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2439 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2440 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2442 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2444 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2446 eina_hash_free(pHttpHeader);
2453 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2455 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2456 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2458 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2460 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2462 eina_hash_free(pHttpHeader);
2469 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2471 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2473 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2474 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2475 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2476 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2478 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2485 _WebImpl::Pause(void)
2487 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2492 _WebImpl::Resume(void)
2494 ewk_view_resume(__pWebCore->GetWebNativeNode());
2499 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2501 __pSelectBox.reset();
2503 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2505 result r = E_SUCCESS;
2507 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2508 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2510 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2511 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2513 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2514 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2516 __pSelectBox = std::move(pSelectBox);
2518 return __pSelectBox->ShowPopup();
2523 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2525 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2527 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2532 _WebImpl::ClearSelectBoxPopup(void)
2534 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2536 __pSelectBox.reset();
2543 _WebImpl::GetDatepicker(void)
2545 _InputPickerPopup* pInputPicker =null;
2548 pInputPicker = __pDatePicker.get();
2550 return pInputPicker;
2555 _WebImpl::GetColorpicker(void)
2557 _InputPickerPopup* pInputPicker =null;
2560 pInputPicker = __pColorPicker.get();
2562 return pInputPicker;
2567 _WebImpl::CanGoBack(void) const
2569 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2574 _WebImpl::CanGoForward(void) const
2576 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2581 _WebImpl::GoBack(void) const
2583 ewk_view_back(__pWebCore->GetWebNativeNode());
2588 _WebImpl::GoForward(void) const
2590 ewk_view_forward(__pWebCore->GetWebNativeNode());
2595 _WebImpl::GetUrl(void) const
2597 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2602 _WebImpl::GetTitle(void) const
2604 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2609 _WebImpl::StopLoading(void) const
2611 ewk_view_stop(__pWebCore->GetWebNativeNode());
2616 _WebImpl::Reload(void) const
2618 ewk_view_reload(__pWebCore->GetWebNativeNode());
2623 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2625 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2631 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2632 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2634 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2635 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2637 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2639 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2640 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2642 pPresenter->WaitAsyncProcess(*pResult.get());
2644 return pResult.release();
2649 _WebImpl::SetZoomLevel(float level)
2651 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);
2653 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2660 _WebImpl::GetZoomLevel(void) const
2662 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2666 const PageNavigationList*
2667 _WebImpl::GetBackForwardListN(void) const
2669 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2675 result r = E_SUCCESS;
2677 _PageNavigationListImpl* pNavigationListImpl = null;
2678 _HistoryItemImpl* pHistoryItemImpl = null;
2680 std::unique_ptr<PageNavigationList> pNavigationList;
2681 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2684 int forwardCount = 0;
2689 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2690 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2692 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2693 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2695 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2696 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2698 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2699 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2701 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2702 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2704 r = pHistoryList->Construct();
2705 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2707 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2708 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2709 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2711 for (int i = -backCount; i < forwardCount + 1; i++)
2713 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2714 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2716 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2717 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2719 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2720 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2722 url = ewk_history_item_uri_get(pEwkItem);
2723 title = ewk_history_item_title_get(pEwkItem);
2724 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2726 pHistoryItemImpl->SetHistoryItem(url, title);
2728 r = pHistoryList->Add(*pHistoryItem.get());
2729 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2730 pHistoryItem.release();
2733 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2735 ewk_history_free(pEwkHistoryList);
2737 return pNavigationList.release();
2740 ewk_history_free(pEwkHistoryList);
2747 _WebImpl::SearchText(const String& text, bool searchForward)
2749 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2755 result r = E_SUCCESS;
2757 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2761 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2764 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2765 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2767 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
2768 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
2771 pPresenter->WaitAsyncProcess(result);
2773 return static_cast < bool >(result);
2778 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2780 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2786 result r = E_SUCCESS;
2788 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2792 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2795 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2796 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2803 _WebImpl::SearchNextAsync(bool searchForward)
2805 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2811 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2812 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2813 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2815 result r = E_SUCCESS;
2817 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2819 if (!__textSearch.__caseSensitive)
2821 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2826 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2829 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2830 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2837 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2839 MutexGuard lock(__mutex);
2841 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2842 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2847 if (__textSearch.__searchAll)
2849 DisableAsyncSearch();
2851 __textSearch.__searchQueue.Enqueue(this);
2852 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2854 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2855 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2859 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2861 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2865 case SEARCH_ALL_ASYNC:
2866 __textSearch.__searchAll = true;
2867 __textSearch.__text = text;
2868 __textSearch.__searchForward = true;
2869 __textSearch.__caseSensitive = caseSensitive;
2870 __textSearch.__totalCount = -1;
2871 __textSearch.__currentIndex = 1;
2873 __textSearch.__searchQueue.Enqueue(this);
2874 __textSearch.__searchQueue.Enqueue(this);
2876 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2877 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2880 case SEARCH_NEXT_ASYNC:
2881 __textSearch.__searchForward = searchForward;
2883 CalculateAsyncSearchOrdinal();
2885 __textSearch.__searchQueue.Enqueue(this);
2887 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2899 _WebImpl::SetAsyncSearchResult(int totalCount)
2901 __textSearch.__totalCount = totalCount;
2906 _WebImpl::GetSearchPresenter(void)
2908 MutexGuard lock(__mutex);
2910 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2915 _WebImpl::GetPendingAsyncSearchCount(void) const
2917 return __textSearch.__searchQueue.GetCount();
2922 _WebImpl::CalculateAsyncSearchOrdinal(void)
2924 if (__textSearch.__searchForward)
2926 __textSearch.__currentIndex++;
2930 __textSearch.__currentIndex--;
2936 _WebImpl::GetAsyncSearchOrdinal(void) const
2938 return __textSearch.__currentIndex;
2943 _WebImpl::DisableAsyncSearch(void)
2945 __textSearch.__searchAll = false;
2950 _WebImpl::SetSetting(const WebSetting& setting)
2952 if (__pWebCore->GetWebNativeNode())
2954 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2955 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2956 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2958 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2959 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2961 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2963 switch (setting.GetCacheControl())
2965 case WEB_CACHE_VALIDATED:
2966 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2969 case WEB_CACHE_IGNORE:
2970 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2977 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2979 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2983 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2986 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2988 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2990 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2992 if (__defaultUserAgent != setting.GetUserAgent())
2994 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2995 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2997 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
3000 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
3002 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
3004 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3006 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3009 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3011 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3012 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3013 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3014 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3015 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3016 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3017 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3018 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3019 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3020 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3021 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3022 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3023 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3030 _WebImpl::GetSetting(void) const
3032 return *__pWebCore->GetSetting();
3036 const HitElementResult*
3037 _WebImpl::GetElementByPointN(const Point& point) const
3039 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3043 const HitElementResult*
3044 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3046 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3052 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));
3054 result r = E_SUCCESS;
3056 _HitElementResultImpl* pHitElementResultImpl = null;
3058 std::unique_ptr<HitElementResult> pHitElementResult;
3059 std::unique_ptr<Bitmap> pImage;
3060 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3062 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3064 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3065 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3067 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3068 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3069 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3070 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3071 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3073 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3075 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3076 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3078 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3079 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3081 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3087 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3088 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3089 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3090 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3092 r = buf.Construct(imageLength);
3093 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3095 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3096 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3100 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3101 // webkit support types such as ico and vp8 additionally
3102 if (strcmp(pExtension, "gif") == 0)
3104 format = IMG_FORMAT_GIF;
3106 else if (strcmp(pExtension, "jpg") == 0)
3108 format = IMG_FORMAT_JPG;
3110 else if (strcmp(pExtension, "png") == 0)
3112 format = IMG_FORMAT_PNG;
3114 else if (strcmp(pExtension, "bmp") == 0)
3116 format = IMG_FORMAT_BMP;
3120 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3124 r = image.Construct();
3125 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3127 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3128 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3133 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3134 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3136 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3137 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3139 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3140 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3143 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3145 ewk_hit_test_free(pEwkHitTest);
3147 return pHitElementResult.release();
3150 ewk_hit_test_free(pEwkHitTest);
3157 _WebImpl::IsLoading(void) const
3159 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3161 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3173 _WebImpl::GetTextFromBlock(void) const
3175 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3180 _WebImpl::IsPrivateBrowsingEnabled(void) const
3182 if (__pWebCore->GetWebNativeNode() == null)
3184 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3187 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3188 SysAssertf(pSettings, "Failed to get webkit instance.");
3190 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3195 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3197 if (__pWebCore->GetWebNativeNode() == null)
3199 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3203 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3204 SysAssertf(pSettings, "Failed to get webkit instance.");
3206 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3211 _WebImpl::ClearHistory(void)
3213 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3218 _WebImpl::ClearCache(void)
3220 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3222 ewk_context_cache_clear(pContext);
3227 _WebImpl::ClearCookie(void)
3229 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3230 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3232 ewk_cookie_manager_cookies_clear(pCookieManager);
3237 _WebImpl::ClearFormData(void)
3239 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3241 ewk_context_form_candidate_data_clear(pContext);
3246 _WebImpl::ClearLoginFormData(void)
3248 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3250 ewk_context_form_password_data_clear(pContext);
3255 _WebImpl::IsCookieEnabled(void) const
3257 if (__pWebCore->GetWebNativeNode() == null)
3259 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3262 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3263 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3264 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3266 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
3267 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3269 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
3271 bool result = false;
3272 pPresenter->WaitAsyncProcess(result);
3279 _WebImpl::SetCookieEnabled(bool enable)
3281 if (__pWebCore->GetWebNativeNode() == null)
3283 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3288 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3289 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3290 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3294 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3298 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3299 ewk_cookie_manager_cookies_clear(pCookieManager);
3305 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3307 result r = E_SUCCESS;
3309 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3310 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3313 String fileExtension = File::GetFileExtension(filePath);
3314 int pathLength = filePath.GetLength();
3317 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3319 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3320 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3321 r = filePath.SubString(0, index + 1, dirPath);
3322 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3324 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3325 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3329 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3331 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3335 Evas_Coord contentsWidth;
3336 Evas_Coord contentsHeight;
3338 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3339 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3347 _WebImpl::IsMimeSupported(const String& mime) const
3349 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3350 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3352 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3357 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3359 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3364 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3366 __pUserUiListener = pUiEventListener;
3371 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3373 __pUserUiListenerF = pUiEventListener;
3378 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3380 __pUserKeypadEventListener = pKeypadEventListener;
3385 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3387 if (__pWebDownloadHandler.get() == null)
3389 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3390 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3393 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3394 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3399 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3401 __pTextSearchListener = pTextSearchListener;
3406 _WebImpl::SetScrollEnabled(bool enable)
3408 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3413 _WebImpl::IsScrollEnabled(void) const
3415 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3420 _WebImpl::InitJsBridgeList(void)
3422 result r = E_SUCCESS;
3424 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3425 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3427 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3428 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3430 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3431 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3433 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3434 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3436 __pJsBridgeList = std::move(pJsBridgeList);
3443 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3445 result r = E_SUCCESS;
3447 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3448 String key(pJsBridge->GetName());
3450 r = __pJsBridgeList->Add(key, pJsBridge);
3451 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3458 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3460 result r = E_SUCCESS;
3462 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3463 String key(pJsBridge->GetName());
3465 r = __pJsBridgeList->Remove(key);
3466 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3473 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3475 result r = E_SUCCESS;
3477 IJsonValue* pJsonValue = null;
3478 IJavaScriptBridge* pJsBridge = null;
3480 String key(L"name");
3482 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3483 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));
3485 r = pJsonObject->GetValue(&key, pJsonValue);
3486 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3488 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3489 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3491 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3492 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3499 _WebImpl::GetLoadingListener(void) const
3501 return __pUserLoadingListener;
3505 IWebUiEventListener*
3506 _WebImpl::GetUiEventListener(void) const
3508 return __pUserUiListener;
3512 IWebUiEventListenerF*
3513 _WebImpl::GetUiEventListenerF(void) const
3515 return __pUserUiListenerF;
3519 IWebKeypadEventListener*
3520 _WebImpl::GetWebKeypadEventListener(void) const
3522 return __pUserKeypadEventListener;
3526 ITextSearchListener*
3527 _WebImpl::GetTextSearchListener(void) const
3529 return __pTextSearchListener;
3534 _WebImpl::SetEventListenerCallback(void) const
3536 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3539 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3540 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3542 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3543 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3545 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3546 SysAssertf(pSmartData, "Failed to request");
3548 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3549 SysAssertf(pSmart, "Failed to request");
3551 pSmart->popup_menu_show = OnSelectBoxRequested;
3552 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3553 pSmart->popup_menu_hide = OnSelectBoxClosed;
3554 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3556 pSmart->input_picker_show = OnDatePickerProviderRequested;
3557 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3558 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3560 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3561 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3562 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3563 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3565 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3567 // add loading event callbacks for ILoadingListener
3568 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3569 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3571 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3572 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3573 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3574 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3575 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3576 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3577 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3578 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3580 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3582 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3584 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3585 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3586 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3588 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3589 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3591 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3593 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3594 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3595 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3597 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3599 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3600 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3601 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3603 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3604 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3605 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3607 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3608 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3609 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3611 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3612 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3613 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3614 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3616 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3617 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3619 evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
3621 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
3622 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
3624 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3625 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3626 SysAssertf(pContext, "Failed to get webkit instance.");
3627 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3628 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3630 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3631 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3632 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3633 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3635 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3641 _WebImpl::RemoveEventListenerCallback(void) const
3643 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3646 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3647 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3649 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3650 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3652 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3653 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3655 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3656 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3657 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3658 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3659 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3660 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3661 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3662 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3664 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3666 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3668 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3669 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3670 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3672 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3673 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3675 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3677 ewk_view_javascript_alert_callback_set(null, null, null);
3678 ewk_view_javascript_prompt_callback_set(null, null, null);
3679 ewk_view_javascript_confirm_callback_set(null, null, null);
3681 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3683 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3684 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3685 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3687 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3688 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3689 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3690 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3691 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3692 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3694 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3695 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3696 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3698 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3700 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3701 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3703 evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
3705 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
3706 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
3708 ewk_view_open_panel_callback_set(null, null, null);
3709 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3710 SysAssertf(pContext, "Failed to get webkit instance.");
3711 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3713 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3714 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3715 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3716 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3718 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3724 _WebImpl::ClearCertificateDb(void)
3726 result r = E_SUCCESS;
3728 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3729 String table(CERTIFICATE_TABLE_NAME);
3732 r = db.Construct(certificatePath, "r+", null);
3733 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3735 db.BeginTransaction();
3737 r = db.ExecuteSql(L"Delete From " + table, true);
3738 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3740 db.CommitTransaction();
3745 db.RollbackTransaction();
3750 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3752 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3757 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3759 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3760 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
3761 if (pSmartData && pSmartData->api)
3763 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3765 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3768 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3770 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3771 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3773 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3775 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3777 ewk_view_command_execute(pView, "SelectWord", 0);
3781 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3782 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3785 ewk_view_command_execute(pView, "SelectWord", 0);
3791 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3793 evas_object_smart_callback_call(pView, "text,selected", NULL);
3800 _WebImpl::ReleaseBlock(void)
3802 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3807 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3809 FloatPoint tempStartPoint;
3810 FloatPoint tempEndPoint;
3812 GetBlockRange(tempStartPoint, tempEndPoint);
3814 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3815 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3820 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3822 Eina_Rectangle leftHandle;
3823 Eina_Rectangle rightHandle;
3825 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3826 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3828 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3830 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3831 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3832 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3833 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3835 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3837 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3838 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3844 _WebImpl::GetFaviconN(void) const
3846 result r = E_SUCCESS;
3848 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3849 Ewk_Context* pContext = ewk_view_context_get(pView);
3850 const char* pUrl = ewk_view_url_get(pView);
3851 Evas* pEvas = evas_object_evas_get(pView);
3853 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3859 Tizen::Graphics::BufferInfo bufferInfo;
3861 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3862 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3864 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3865 Tizen::Base::ByteBuffer byteBuffer;
3867 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3868 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3870 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3871 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3873 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3874 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3876 return pImage.release();
3882 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3884 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3889 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3891 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3896 _WebImpl::GetScrollPosition(void) const
3900 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3907 _WebImpl::GetPageSize(void) const
3909 Evas_Coord width = 0;
3910 Evas_Coord height = 0;
3912 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3914 Dimension size(static_cast< int >(width), static_cast< int >(height));
3921 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
3923 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3925 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3926 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3928 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
3930 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
3937 _WebImpl::RemoveHttpHeaderField(const String& name)
3939 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3941 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3942 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3944 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
3951 _WebImpl::SetLoadingErrorOccurred(bool arg)
3953 __isLoadingErrorOccurred = arg;
3958 _WebImpl::IsLoadingErrorOccurred(void) const
3960 return __isLoadingErrorOccurred;
3965 _WebImpl::SetRedirectRequested(bool arg)
3967 __isRedirectRequested = arg;
3972 _WebImpl::IsRedirectRequested(void) const
3974 return __isRedirectRequested;
3979 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3986 _WebImpl::GetPolicyDecision(void) const
3993 _WebImpl::SetCertificateRequested(bool arg)
3995 __isCertificateRequested = arg;
4000 _WebImpl::IsCertificateRequested(void) const
4002 return __isCertificateRequested;
4007 _WebImpl::SetCertificateConfirmed(bool arg)
4009 __isCertificateConfirmed = arg;
4014 _WebImpl::IsCertificateConfirmed(void) const
4016 return __isCertificateConfirmed;
4021 _WebImpl::SetFullScreenKeypad(void)
4023 result r = E_SUCCESS;
4025 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4026 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4028 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4029 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4031 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4032 pKeypad->SetText(text);
4034 r = pKeypad->SetShowState(true);
4035 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4037 r = pKeypad->Show();
4038 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4040 pKeypad->AddTextEventListener(*this);
4042 __pKeypad = std::move(pKeypad);
4049 _WebImpl::RemoveFullScreenKeypad(void)
4051 __pKeypad->RemoveTextEventListener(*this);
4058 _WebImpl::IsFooterVisible(void) const
4060 return __isFooterVisible;
4065 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4067 __isFooterVisible = isFooterVisible;
4072 _WebImpl::IsKeypadVisible(void) const
4074 return __isKeypadVisible;
4079 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4081 __isKeypadVisible = isKeypadVisible;
4086 _WebImpl::IsKeypadOpened(void) const
4088 return __isKeypadOpened;
4092 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4094 __isKeypadOpened = isKeypadOpened;
4099 _WebImpl::GetPreviousKeypadBounds(void) const
4101 return __keypadBounds;
4106 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4108 __keypadBounds = bounds;
4113 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4115 RemoveFullScreenKeypad();
4120 _WebImpl::OnTextValueChanged(const Control& source)
4122 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4124 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4126 RemoveFullScreenKeypad();
4131 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4133 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4134 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4136 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4137 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4139 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4140 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4142 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4149 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4151 result r = E_SUCCESS;
4153 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4154 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4156 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4158 ILoadingListener* pLoadingListner = GetLoadingListener();
4159 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4161 switch (pEventArg->GetEventType())
4163 case WEB_EVENT_LOADINGLISTENER_STARTED:
4165 pLoadingListner->OnLoadingStarted();
4169 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4171 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4172 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4174 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4178 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4180 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4181 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4183 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4187 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4189 pLoadingListner->OnLoadingCanceled();
4193 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4195 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4196 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4198 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4199 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4201 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4203 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4207 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4209 pLoadingListner->OnLoadingCompleted();
4213 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4215 pLoadingListner->OnHttpAuthenticationCanceled();
4219 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4221 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4222 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4226 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4242 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4244 result r = E_SUCCESS;
4246 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4247 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4249 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4251 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4252 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4254 switch (pEventArg->GetEventType())
4256 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4258 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4259 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4261 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4265 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4267 pWebDownloadListener->OnWebDataDownloadCompleted();
4271 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4273 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4274 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4276 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4278 pWebDownloadListener->OnWebDownloadFailed(errorType);
4293 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4295 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4296 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4298 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4300 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4302 switch (pEventArg->GetEventType())
4304 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4306 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4308 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4309 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4311 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4312 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4314 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4318 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4320 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4322 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4326 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4328 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4330 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4334 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4336 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4338 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4339 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4341 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4356 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4358 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4359 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4361 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4363 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4365 switch (pEventArg->GetEventType())
4367 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4369 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4371 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4372 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4374 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4375 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4377 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4381 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4383 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4385 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4389 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4391 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4393 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4397 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4399 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4401 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4402 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4404 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4419 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4421 result r = E_SUCCESS;
4423 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4424 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4426 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4428 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4429 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4431 switch (pEventArg->GetEventType())
4433 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4435 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4436 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4438 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4439 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4441 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4456 _WebImpl::VibrationRequested(uint64_t duration)
4458 result r = E_SUCCESS;
4460 __pVibrator.reset();
4462 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4463 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4465 r = pVibrator->Construct();
4466 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4468 __pVibrator = std::move(pVibrator);
4470 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4472 r = __pVibrator->Start(&pattern, 1, 1);
4473 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4480 _WebImpl::VibrationCanceled(void)
4482 __pVibrator.reset();
4487 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4489 result r = E_SUCCESS;
4491 String host(ewk_auth_challenge_url_get(pChallenge));
4492 String realm(ewk_auth_challenge_realm_get(pChallenge));
4494 __pAuthChallenge.reset();
4496 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4497 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4499 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4500 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4502 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4503 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4505 __pAuthChallenge = std::move(pAuthChallenge);
4507 ewk_auth_challenge_suspend(pChallenge);
4508 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4510 __pAuthChallenge.release();
4514 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4515 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4523 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4525 result r = E_SUCCESS;
4527 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4528 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4530 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4531 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4533 __pAuthPopup = std::move(pAuthPopup);
4535 int modalResult = 0;
4537 r = __pAuthPopup->ShowAndWait(modalResult);
4538 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4543 __pAuthPopup.reset();
4551 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4553 result r = E_SUCCESS;
4555 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4556 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4558 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4559 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4561 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4563 int modalResult = 0;
4565 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4566 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4568 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4570 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4574 if (__pCertConfirmPopup.get())
4576 __pCertConfirmPopup.reset();
4584 _WebImpl::ShowPromptPopup(String msg, String defVal)
4586 result r = E_SUCCESS;
4588 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4589 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4591 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
4592 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4594 __pPromptPopup = std::move(pPromptPopup);
4596 r = __pPromptPopup->ShowPopup();
4597 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4602 __pPromptPopup.reset();
4610 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4612 result r = E_SUCCESS;
4614 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4615 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4617 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
4618 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4620 int modalResult = 0;
4622 switch(userConfirmMode)
4624 case USER_CONTENT_HANDLER:
4626 __pContentHandlerConfirmPopup.reset();
4628 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4630 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4631 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4634 case USER_PROTOCOL_HANDLER:
4636 __pProtocolHandlerConfirmPopup.reset();
4638 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4640 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4641 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4644 case USER_CONFIRM_APP_CACHE:
4646 __pAppCacheConfirmPopup.reset();
4648 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4650 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4651 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4654 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4656 __pDbQuotaConfirmPopup.reset();
4658 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4660 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4661 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4664 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4666 __pLocalFsQuotaConfirmPopup.reset();
4668 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4670 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4671 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4674 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4676 __pIndexedDbQuotaConfirmPopup.reset();
4678 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4680 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4681 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4693 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4695 result r = E_SUCCESS;
4697 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4698 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4700 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
4701 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4703 switch(userConfirmMode)
4705 case USER_CONFIRM_USERMEDIA:
4707 __pUserMediaConfirmPopup.reset();
4709 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4711 r = __pUserMediaConfirmPopup->ShowPopup();
4712 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4714 __pUserMediaConfirmPopup.release();
4717 case USER_CONFIRM_GEOLOCATION:
4719 __pGeolocationConfirmPopup.reset();
4721 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4723 r = __pGeolocationConfirmPopup->ShowPopup();
4724 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4726 __pGeolocationConfirmPopup.release();
4729 case USER_CONFIRM_NOTIFICATION:
4731 __pNotificationConfirmPopup.reset();
4733 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4735 r = __pNotificationConfirmPopup->ShowPopup();
4736 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4738 __pNotificationConfirmPopup.release();
4741 case USER_SCRIPT_ALERT:
4743 __pScriptAlertConfirmPopup.reset();
4745 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4747 r = __pScriptAlertConfirmPopup->ShowPopup();
4748 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4750 __pScriptAlertConfirmPopup.release();
4765 _WebImpl::GetParentFormCore(_Control* pControlCore)
4768 _Form* pFormCore = null;
4770 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4771 if (!pParentControlCore)
4776 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4782 return GetParentFormCore(pParentControlCore);
4787 _WebImpl::OnFocusGained(const _ControlImpl& source)
4789 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4790 SysAssertf(pSettings, "Failed to get webkit instance.");
4791 ewk_settings_clear_text_selection_automatically_set(pSettings, true);
4793 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_TRUE);
4800 _WebImpl::OnFocusLost(const _ControlImpl& source)
4802 if(IsKeypadVisible() == true)
4804 SetKeypadOpened(true);
4806 SetKeypadVisibleState(false);
4809 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4810 SysAssertf(pSettings, "Failed to get webkit instance.");
4811 ewk_settings_clear_text_selection_automatically_set(pSettings, false);
4813 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4820 _WebImpl::HasValidNativeNode(void) const
4822 if (__pWebCore && __pWebCore->GetWebNativeNode())
4832 _WebImpl::OnPreAttachedToMainTree(void)
4834 result r = E_SUCCESS;
4836 r = __pWebCore->InitializeWebNativeNode();
4837 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4839 r = InitializeSetting();
4840 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4842 r = _ContainerImpl::OnPreAttachedToMainTree();
4843 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4850 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4856 case _CONTROL_ROTATION_0:
4859 case _CONTROL_ROTATION_90:
4862 case _CONTROL_ROTATION_180:
4865 case _CONTROL_ROTATION_270:
4871 ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree);
4876 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4878 _ContainerImpl::OnChangeLayout(orientation);
4880 if (__pColorPicker.get())
4882 __pColorPicker->ChangeLayout(orientation);
4885 HideFormDataWindow();
4887 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4888 _WebNotification* pWebNotification = null;
4890 while (pEnum->MoveNext() == E_SUCCESS)
4892 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4893 pWebNotification->OnChangeLayout();
4899 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4901 if (IsVisible() == true)
4903 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4907 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4913 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4915 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
4919 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4920 __pCertConfirmPopup.reset();
4922 case ID_PROMPT_POPUP_CLOSE:
4923 __pPromptPopup.reset();
4925 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
4926 __pUserMediaConfirmPopup.reset();
4928 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
4929 __pGeolocationConfirmPopup.reset();
4931 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
4932 __pNotificationConfirmPopup.reset();
4934 case ID_USER_SCRIPT_ALERT_CLOSE:
4935 __pScriptAlertConfirmPopup.reset();
4944 _WebImpl::GetDownloadHandler(void) const
4946 return __pWebDownloadHandler.get();
4951 _WebImpl::HideColorPicker(void)
4953 __pColorPicker.reset();
4960 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4962 result r = E_SUCCESS;
4964 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4965 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4967 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4969 r = pColorHadler->Construct(colorVal, this);
4970 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4972 __pColorPicker = std::move(pColorHadler);
4974 r = __pColorPicker->ShowPopup();
4975 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4979 color = __pColorPicker->GetColor();
4985 __pColorPicker.reset();
4993 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4995 result r = E_SUCCESS;
4997 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4998 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5000 r = pInputPicker->Construct(String(inputValue), inputType, this);
5001 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5003 __pDatePicker = std::move(pInputPicker);
5005 r = __pDatePicker->ShowPopup();
5006 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5010 dateStr = __pDatePicker->GetDate();
5016 __pDatePicker.reset();
5024 _WebImpl::GetInstance(Web* pWeb)
5026 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5031 _WebImpl::GetInstance(const Web* pWeb)
5033 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5038 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5040 int checkReturn = 0;
5042 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5045 if( checkmime == true)
5047 table = CUSTOM_CONTENT_TABLE_NAME;
5051 table = CUSTOM_PROTOCOL_TABLE_NAME;
5054 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5055 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5056 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5058 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5060 result r = db.Construct(handlerPath, "r+", null);
5061 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5063 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"'"));
5064 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5068 r = pEnum->MoveNext();
5069 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5070 r = pEnum->GetIntAt(0, checkReturn);
5071 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5083 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5087 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5090 if( checkmime == true)
5092 table = CUSTOM_CONTENT_TABLE_NAME;
5096 table = CUSTOM_PROTOCOL_TABLE_NAME;
5099 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5100 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5101 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5103 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5105 result r = db.Construct(handlerPath, "r+", null);
5106 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5108 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"'"));
5109 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5113 r = pEnum->MoveNext();
5114 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5115 r = pEnum->GetIntAt(0, checkId);
5116 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5118 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5119 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5121 r = pDeleteStmt->BindInt(0, checkId);
5122 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5124 db.BeginTransaction();
5126 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5128 db.CommitTransaction();
5135 const Tizen::Base::String
5136 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5138 if (originUri == L"" || currentUri == L"")
5143 result r = E_SUCCESS;
5146 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5147 String originReplace(originUri);
5148 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5152 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5153 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5155 r = currentUri.SubString(0, found + 1, baseUri);
5156 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5158 r = db.Construct(handlerPath, "r+", null);
5159 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5161 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5162 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5166 while (pEnum->MoveNext() == E_SUCCESS)
5171 String originScheme;
5173 r = pEnum->GetStringAt(0, protocol);
5174 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5176 r = pEnum->GetStringAt(1, queryUrl);
5177 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5179 r = pEnum->GetIntAt(2, allow);
5180 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5187 String protocolScheme(protocol + L":");
5189 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5190 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5192 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5194 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5196 r = originReplace.Replace(originScheme, "");
5197 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5199 queryUrl.Replace("%s", originReplace, 0);
5200 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5212 const Tizen::Base::String
5213 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5215 if (originUri == L"" || currentUri == L"" || mime == L"")
5220 result r = E_SUCCESS;
5223 String originUrlStr = originUri;
5224 const String replaceStr = L"%s";
5226 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5227 String table(CUSTOM_CONTENT_TABLE_NAME);
5231 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5232 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5234 r = currentUri.SubString(0, found + 1, baseUri);
5235 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5237 r = db.Construct(handlerPath, "r+", null);
5238 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5240 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5244 r = pEnum->MoveNext();
5245 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5246 r = pEnum->GetIntAt(0, allow);
5247 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5248 r = pEnum->GetStringAt(1, contentUrl);
5249 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5257 if (contentUrl != L"")
5259 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5260 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5272 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5274 __pFormDataList = pFormDataList;
5279 _WebImpl::IsFormDataWindowVisible(void) const
5281 return __isFormDataVisible;
5286 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5288 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5290 if (__isFormDataVisible)
5292 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5293 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5297 __pFormDataWindow.reset();
5299 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5300 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5302 result r = pFormDataWindow->Construct(rect, this, pWebView);
5303 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5305 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5306 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5308 r = pFormDataWindow->LaunchFormDataWindow();
5309 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5311 __pFormDataWindow = std::move(pFormDataWindow);
5312 __isFormDataVisible = true;
5320 _WebImpl::HideFormDataWindow(bool delWindow)
5324 __pFormDataWindow.reset();
5327 __isFormDataVisible = false;
5332 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5334 __webNotificationList.Remove(*pWebNotification);
5339 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5341 __webNotificationList.Add(pWebNotification);
5346 _WebImpl::OnDownloadCompleted(RequestId reqId, const String &path)
5348 _ContentManagerImpl::ScanFile(path);
5352 }}} // Tizen::Web::Controls