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_FormImpl.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 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
366 String msg(pMessage);
368 r = pImpl->ShowUserConfirmPopup(USER_SCRIPT_CONFIRM, pView, msg);
369 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
376 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
378 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
380 result r = E_SUCCESS;
381 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
383 String msg(pMessage);
384 String defVal(pDefaultValue);
386 r = pImpl->ShowPromptPopup(msg, defVal);
387 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
392 ewk_view_javascript_prompt_reply(pView, null);
399 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
401 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
402 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
403 SysAssertf(pImpl && pPolicy, "Failed to request");
405 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
407 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
409 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
411 if (pImpl->IsCertificateRequested())
413 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
417 result r = E_SUCCESS;
419 std::unique_ptr<DbEnumerator> pEnum;
421 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
422 String table(CERTIFICATE_TABLE_NAME);
425 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
427 r = db.Construct(certificatePath, "r", null);
428 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
430 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
433 r = pEnum->MoveNext();
434 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
437 r = pEnum->GetIntAt(0, allow);
438 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
440 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
442 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
443 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
447 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
448 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
450 ewk_view_resume(pWebCore->GetWebNativeNode());
455 pImpl->SetCertificateRequested(true);
459 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
460 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
462 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
463 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
472 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
473 pImpl->SetCertificateConfirmed(false);
474 pImpl->SetCertificateRequested(true);
476 ewk_view_resume(pWebCore->GetWebNativeNode());
481 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
483 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
484 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
485 SysAssertf(pImpl && pChallenge, "Failed to request");
487 result r = E_SUCCESS;
489 r = pImpl->HttpAuthenticationRequested(pChallenge);
490 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
494 ewk_auth_challenge_credential_cancel(pChallenge);
495 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
500 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
502 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
503 SysAssertf(pImpl , "Failed to request");
505 if (pImpl->GetLoadingListener())
507 result r = E_SUCCESS;
509 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
510 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
512 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
513 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
519 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
521 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
522 SysAssertf(pImpl , "Failed to request");
524 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
526 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
527 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
529 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
530 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
537 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
539 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
540 SysAssertf(pImpl , "Failed to request");
542 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
544 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
545 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
547 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
548 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
555 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
557 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
558 SysAssertf(pImpl , "Failed to request");
560 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
562 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
563 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
565 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
566 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
572 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
574 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
575 SysAssertf(pImpl , "Failed to request");
577 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
579 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
580 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
582 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
583 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
590 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
592 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
593 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
594 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
596 if (pImpl->GetSetting().IsGeolocationEnabled())
598 result r = E_SUCCESS;
600 std::unique_ptr<DbEnumerator> pEnum;
602 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
603 String table(GEOLOCATION_TABLE_NAME);
606 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
607 String origin = _Utility::CreateOrigin(pSecurityOrigin);
609 r = db.Construct(geolocationPath, "r", null);
610 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
612 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
615 r = pEnum->MoveNext();
616 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
619 r = pEnum->GetIntAt(0, permission);
620 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
622 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
624 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
628 ewk_geolocation_permission_request_suspend(pPermissionRequest);
630 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
631 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
638 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
643 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
645 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
646 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
647 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
649 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
650 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
654 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
659 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
661 result r = E_SUCCESS;
662 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
664 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
665 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
667 ewk_notification_permission_request_suspend(pPermissionRequest);
669 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
670 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
674 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
679 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
681 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
682 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
683 SysAssertf(pImpl && pNotification, "Failed to request");
685 result r = E_SUCCESS;
686 Ewk_Context* pContext = ewk_view_context_get(pView);
687 SysAssertf(pContext, "Failed to get webkit instance.");
688 uint64_t notificationId = ewk_notification_id_get(pNotification);
690 //ewk_notification_security_origin_get(pNotification)
692 const char* text = ewk_notification_body_get(pNotification);
693 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
695 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
696 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
698 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
699 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
701 pNotificationWindow->SetText(String(text));
702 pNotificationWindow->LaunchNotification();
703 pImpl->SetWebNotification(pNotificationWindow.release());
705 ewk_notification_showed(pContext, notificationId);
710 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
712 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
713 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
714 SysAssertf(pImpl && pNotificationID, "Failed to request");
716 //ToDo : Where is ewk API for cancel operation?
721 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
723 result r = E_SUCCESS;
724 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
725 SysAssertf(pImpl, "Failed to request");
727 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
728 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
733 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
735 int checkHandler = 0;
736 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
737 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
738 SysAssertf(pImpl && pHandlerData, "Failed to request");
740 checkHandler = pImpl->SearchHandler(pHandlerData, false);
741 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
742 switch (checkHandler)
747 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
750 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
753 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
761 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
763 result r = E_SUCCESS;
764 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
765 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
766 SysAssertf(pImpl && pHandlerData, "Failed to request");
768 r = pImpl->UnregistrationHandler(pHandlerData, false);
769 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
774 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
776 result r = E_SUCCESS;
777 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
778 SysAssertf(pImpl, "Failed to request");
780 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
781 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
786 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
788 int checkHandler = 0;
789 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
790 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
791 SysAssertf(pImpl && pHandlerData, "Failed to request");
793 checkHandler = pImpl->SearchHandler(pHandlerData, true);
794 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
796 switch (checkHandler)
801 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
804 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
807 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
816 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
818 result r = E_SUCCESS;
819 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
820 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
821 SysAssertf(pImpl && pHandlerData, "Failed to request");
823 r = pImpl->UnregistrationHandler(pHandlerData, true);
824 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
829 OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo)
831 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
832 SysAssertf(pImpl, "Failed to request");
834 SysLog(NID_WEB_CTRL, "Enter.");
839 OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
841 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
842 SysAssertf(pImpl, "Failed to request");
844 SysLog(NID_WEB_CTRL, "Exit.");
849 OnVibrationRequested(uint64_t duration, void* pUserData)
851 result r = E_SUCCESS;
853 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
854 SysAssertf(pImpl, "Failed to request");
856 r = pImpl->VibrationRequested(duration);
857 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
862 OnVibrationCanceled(void* pUserData)
864 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
865 SysAssertf(pImpl, "Failed to request");
867 pImpl->VibrationCanceled();
872 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
874 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
875 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
876 SysAssertf(pImpl && pPolicy, "Failed to request");
878 String url(ewk_policy_decision_url_get(pPolicy));
879 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
881 if (url == L"about:blank")
883 ewk_policy_decision_use(pPolicy);
887 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
888 && !pImpl->IsRedirectRequested())
890 pImpl->SetCertificateRequested(false);
892 if (pImpl->GetTextSearchListener())
894 pImpl->DisableAsyncSearch();
897 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
898 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
900 switch (ewkNavigationType)
902 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
903 navigationType = WEB_NAVIGATION_LINK_CLICKED;
905 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
906 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
908 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
909 navigationType = WEB_NAVIGATION_BACKFORWARD;
911 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
912 navigationType = WEB_NAVIGATION_RELOAD;
914 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
915 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
917 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
918 navigationType = WEB_NAVIGATION_OTHER;
924 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
926 ewk_policy_decision_ignore(pPolicy);
932 String currentUrl(pImpl->GetUrl());
933 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
934 if (redirectUrl != L"")
936 pImpl->LoadUrl(redirectUrl);
937 ewk_policy_decision_ignore(pPolicy);
945 String uriScheme(uri.GetScheme());
946 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
948 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
950 ewk_policy_decision_ignore(pPolicy);
952 if (uriScheme == L"")
957 result r = E_SUCCESS;
959 if (uriScheme == L"tel")
961 String operationId(L"http://tizen.org/appcontrol/operation/dial");
962 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
964 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
966 String operationId(L"http://tizen.org/appcontrol/operation/compose");
967 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
971 String operationId(L"http://tizen.org/appcontrol/operation/view");
972 String mime(ewk_policy_decision_response_mime_get(pPolicy));
973 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
975 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
980 ewk_policy_decision_use(pPolicy);
985 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
987 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
988 SysAssertf(pImpl, "Failed to request");
990 if (pImpl->GetLoadingListener())
992 result r = E_SUCCESS;
994 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
995 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
997 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
998 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1005 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1007 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1008 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1009 SysAssertf(pImpl, "Failed to request");
1011 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1013 if (pImpl->GetLoadingListener())
1015 result r = E_SUCCESS;
1017 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1018 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1019 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1021 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1022 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1023 pPageTitle.release();
1025 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1026 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1027 pEventArg.release();
1033 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1035 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1036 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1037 SysAssertf(pImpl, "Failed to request");
1039 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1041 if (pImpl->GetLoadingListener())
1043 result r = E_SUCCESS;
1045 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1046 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1047 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1049 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1050 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1051 pProgressPercentage.release();
1053 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1054 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1055 pEventArg.release();
1061 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1063 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1064 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1065 SysAssertf(pImpl && pPolicy, "Failed to request");
1067 result r = E_SUCCESS;
1069 _SystemResource* pSysResource = _SystemResource::GetInstance();
1070 SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
1072 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1073 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1074 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1075 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1077 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1079 String url(ewk_policy_decision_url_get(pPolicy));
1081 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1083 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1085 DecisionPolicy policy;
1086 HttpHeader httpHeader;
1088 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1090 pImpl->SetRedirectRequested(true);
1094 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1095 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1097 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1098 pImpl->SetPolicyDecision(policy);
1101 switch (pImpl->GetPolicyDecision())
1103 case WEB_DECISION_CONTINUE:
1105 String currentUrl(pImpl->GetUrl());
1106 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1107 if (redirectUrl != L"")
1109 pImpl->LoadUrl(redirectUrl);
1110 ewk_policy_decision_ignore(pPolicy);
1115 if (pImpl->IsMimeSupported(mime) || mime == L"")
1122 ewk_policy_decision_ignore(pPolicy);
1124 String operationId(L"http://tizen.org/appcontrol/operation/view");
1126 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1127 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1129 if (r == E_OBJ_NOT_FOUND)
1131 _SelectBox* pSelectBox = new (std::nothrow) _SelectBox;
1132 SysTryReturnVoidResult(NID_WEB_CTRL, pSelectBox, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1134 r = pSelectBox->Construct(false, L"Select application", 1, null, url);
1135 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1137 pSelectBox->AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1138 r = pSelectBox->ShowPopup();
1139 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1146 case WEB_DECISION_DOWNLOAD:
1148 ewk_policy_decision_ignore(pPolicy);
1150 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1151 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1153 Ewk_Context* pContext = ewk_view_context_get(pView);
1154 SysAssertf(pContext, "Failed to get webkit instance.");
1156 pDownloadHandler->StartDownload(pUrl);
1160 case WEB_DECISION_IGNORE:
1162 ewk_policy_decision_ignore(pPolicy);
1172 ewk_policy_decision_use(pPolicy);
1177 ewk_policy_decision_ignore(pPolicy);
1182 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1184 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1185 SysAssertf(pImpl, "Failed to request");
1187 if (pImpl->IsRedirectRequested())
1189 pImpl->SetRedirectRequested(false);
1192 if (pImpl->IsLoadingErrorOccurred())
1194 pImpl->SetLoadingErrorOccurred(false);
1195 evas_object_smart_callback_call(pView, "load,finished", NULL);
1201 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1203 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1204 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1205 SysAssertf(pImpl && pErrorData, "Failed to request");
1207 int code = ewk_error_code_get(pErrorData);
1208 const char* pDescription = ewk_error_description_get(pErrorData);
1210 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1214 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1215 pImpl->SetLoadingErrorOccurred(true);
1218 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1219 evas_object_smart_callback_call(pView, "load,finished", NULL);
1222 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1223 pImpl->SetLoadingErrorOccurred(true);
1224 evas_object_smart_callback_call(pView, "load,stop", NULL);
1228 pImpl->SetLoadingErrorOccurred(true);
1229 if (pImpl->GetLoadingListener())
1231 result r = E_SUCCESS;
1233 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1234 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1242 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1244 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1245 SysAssertf(pImpl, "Failed to request");
1247 if (pImpl->GetLoadingListener())
1249 result r = E_SUCCESS;
1251 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1252 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1254 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1255 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1256 pEventArg.release();
1263 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1265 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1266 SysAssertf(pImpl, "Failed to request");
1268 if (pImpl->GetLoadingListener())
1270 result r = E_SUCCESS;
1272 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1273 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1275 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1276 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1277 pEventArg.release();
1284 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1286 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1287 SysAssertf(pImpl, "Failed to request");
1289 if (pImpl->GetLoadingListener())
1291 result r = E_SUCCESS;
1293 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1294 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1296 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1297 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1298 pEventArg.release();
1305 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1307 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1308 SysAssertf(pUrl && pImpl != null, "Failed to request");
1310 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1315 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1317 result r = E_SUCCESS;
1319 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1320 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1322 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1323 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1324 pEventArg.release();
1331 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1333 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1334 SysAssertf(pImpl, "Failed to request");
1336 if (pImpl->GetUiEventListener())
1338 result r = E_SUCCESS;
1340 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1341 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1343 if (pImpl->GetUiEventListenerF())
1345 result r = E_SUCCESS;
1347 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1348 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1354 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1356 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1357 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1358 SysAssertf(pParentImpl && pChildView, "Failed to request");
1360 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1361 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1362 if (pUserUiListener)
1364 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1367 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1368 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1370 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1371 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1374 if (pUserUiListenerF)
1376 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1379 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1380 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1382 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1383 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1390 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1392 result r = E_SUCCESS;
1394 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1395 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1397 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1398 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1399 pEventArg.release();
1406 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1408 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1409 SysAssertf(pChildImpl, "Failed to request");
1411 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1412 if (pParentImpl == null)
1417 if (pParentImpl->GetUiEventListener())
1419 result r = E_SUCCESS;
1421 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1422 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1424 if (pParentImpl->GetUiEventListenerF())
1426 result r = E_SUCCESS;
1428 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1429 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1435 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1437 result r = E_SUCCESS;
1439 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1440 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1441 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1443 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1444 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1445 pPreventTrigger.release();
1447 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1448 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1449 pEventArg.release();
1456 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1458 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1459 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1460 SysAssertf(pImpl && pTrigger, "Failed to request");
1462 if (pImpl->GetUiEventListener())
1464 result r = E_SUCCESS;
1466 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1467 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1469 if (pImpl->GetUiEventListenerF())
1471 result r = E_SUCCESS;
1473 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1474 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1480 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1482 result r = E_SUCCESS;
1484 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1485 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1486 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1488 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1490 if ((endPoint->x != 0) && (endPoint->y != 0))
1492 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1493 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1495 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1496 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1497 startPoint.release();
1499 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1500 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1503 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1504 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1505 pEventArg.release();
1513 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1515 result r = E_SUCCESS;
1517 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1518 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1520 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1522 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1524 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1526 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1527 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1529 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1530 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1531 startPoint.release();
1533 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1534 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1537 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1538 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1539 pEventArg.release();
1547 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1549 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1550 SysAssertf(pImpl, "Failed to request");
1552 if (pImpl->GetUiEventListener())
1554 result r = E_SUCCESS;
1556 r = FireWebPageBlockSelectedEvent(pImpl);
1557 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1559 if (pImpl->GetUiEventListenerF())
1561 result r = E_SUCCESS;
1563 r = FireWebPageBlockSelectedEventF(pImpl);
1564 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1570 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1572 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1573 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1575 pMediaListener->Construct(pView);
1578 result r = extraData.Construct();
1579 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_TRUE, r, "[%s] Propagating.", GetErrorMessage(r));
1581 String isMultipleSelection(L"single");
1582 String mode(L"selectionType");
1583 String type(L"type");
1584 String fileType = L"*/*";
1585 String operationId = L"http://tizen.org/appcontrol/operation/pick";
1589 isMultipleSelection.Append(L"multiple");
1592 if (eina_list_count(pAcceptTypes) == 1)
1594 String item((char*)eina_list_nth(pAcceptTypes, 0));
1595 String captureString(pCapture);
1597 if (item.StartsWith("image/",0))
1599 if (captureString == L"camera")
1601 fileType = L"image/jpg";
1602 operationId = L"http://tizen.org/appcontrol/operation/create_content";
1603 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
1604 String typeVal = L"false";
1605 extraData.Add(&typeKey, &typeVal);
1609 fileType = L"image/*";
1610 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1611 extraData.Add(&selectKey, &isMultipleSelection);
1614 else if (item.StartsWith("audio/",0))
1616 fileType = L"audio/*";
1617 //TO DO: as microphone is not supported yet. suggest to throw an exception
1618 //if (captureString == L"microphone")
1620 //operationId = L"http://tizen.org/appcontrol/operation/create_content";
1624 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1625 extraData.Add(&selectKey, &isMultipleSelection);
1628 else if (item.StartsWith("video/",0))
1630 if (captureString == L"camcorder")
1632 fileType = L"video/3gpp";
1633 operationId = L"http://tizen.org/appcontrol/operation/create_content";
1634 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
1635 String typeVal = L"false";
1636 extraData.Add(&typeKey, &typeVal);
1640 fileType = L"video/*";
1641 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1642 extraData.Add(&selectKey, &isMultipleSelection);
1647 r = _AppControlImpl::FindAndStart(operationId, null, &fileType, null, &extraData, pMediaListener.get());
1648 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1650 pMediaListener.release();
1655 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1661 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1663 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1664 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1665 SysAssertf(pImpl && pJsonText, "Failed to request");
1667 result r = E_SUCCESS;
1669 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1671 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1672 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1674 r = pEventArg->Construct(pJsonText);
1675 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1677 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1678 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1679 pEventArg.release();
1684 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1686 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1687 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1688 SysAssertf(pImpl && pEinaRect, "Failed to request");
1690 if (pImpl->IsVisible() == false)
1692 evas_object_focus_set(pView, EINA_FALSE);
1695 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1697 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1698 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1700 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1702 if (rect.height == 0)
1707 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1710 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1712 if (pFormImpl->HasFooter())
1714 pFormImpl->GetCore().SetKeypadShowState(true);
1719 if (pImpl->GetWebKeypadEventListener())
1721 if (pImpl->IsKeypadVisible() == true)
1723 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1725 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1730 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1733 pImpl->SetKeypadVisibleState(true);
1734 pImpl->SetPreviousKeypadBounds(rect);
1738 result r = pImpl->SetFullScreenKeypad();
1739 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1745 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1747 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1748 SysAssertf(pImpl, "Failed to request");
1750 if (pImpl->GetWebKeypadEventListener())
1752 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1758 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1760 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1761 SysAssertf(pImpl, "Failed to request");
1763 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1766 pFormImpl->DeflateClientRectHeight(0);
1768 if (pFormImpl->HasFooter())
1770 pFormImpl->GetCore().SetKeypadShowState(false);
1775 if (pImpl->GetWebKeypadEventListener())
1777 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1780 pImpl->SetKeypadVisibleState(false);
1785 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1787 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1788 SysAssertf(pImpl, "Failed to request");
1790 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true && pImpl->IsFocused() == true)
1792 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1793 SysAssertf(pWebCore, "Failed to get Web core object");
1795 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1797 pImpl->SetKeypadVisibleState(true);
1803 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1805 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1806 SysAssertf(pImpl, "Failed to request");
1808 if (pImpl->IsKeypadOpened() == true)
1810 pImpl->SetKeypadOpened(false);
1816 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1818 SysAssertf(pSmartData, "invalid smartdata");
1819 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1820 SysAssertf(pWebImpl, "Failed to get Impl");
1822 result r = E_SUCCESS;
1824 if (pWebImpl->GetColorpicker())
1831 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1832 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1834 byte r1, g1, b1, a1;
1835 color.GetColorComponents(r1, g1, b1, a1);
1836 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1843 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1845 SysAssertf(pSmartData, "invalid smartdata");
1847 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1848 SysAssertf(pWebImpl, "Failed to get Impl");
1850 return pWebImpl->HideColorPicker();
1855 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1857 SysAssertf(pSmartData, "Failed to request");
1858 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1859 SysAssertf(pWebImpl, "Failed to get Impl");
1861 result r = E_SUCCESS;
1863 if (pWebImpl->GetDatepicker())
1865 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1872 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1873 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1875 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1876 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1878 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1885 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1887 SysAssertf(pSmartData, "Failed to request");
1889 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1890 SysAssertf(pWebImpl, "Failed to get Impl");
1892 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1893 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1900 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1902 SysAssertf(pSmartData, "Failed to request");
1904 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1905 SysAssertf(pWebImpl, "Failed to get Impl");
1907 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1908 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1915 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1917 SysAssertf(pSmartData, "invalid smartdata");
1919 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1920 SysAssertf(pWebImpl, "Failed to get Impl");
1922 result r = pWebImpl->ClearSelectBoxPopup();
1923 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1930 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1932 SysAssertf(pSmartData, "invalid smartdata");
1934 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1935 SysAssertf(pWebImpl, "Failed to get Impl");
1937 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1938 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1945 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1947 SysAssertf(pSmartData, "Failed to request");
1949 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1950 SysAssertf(pWebImpl, "Failed to get Impl");
1952 Rectangle windowRect(x, y, w, h);
1953 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1954 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1961 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
1963 SysAssertf(pSmartData, "Failed to request");
1965 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1966 SysAssertf(pWebImpl, "Failed to get Impl");
1968 if (pWebImpl->IsFormDataWindowVisible())
1970 pWebImpl->HideFormDataWindow();
1978 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
1980 SysAssertf(pSmartData, "Failed to request");
1982 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1983 SysAssertf(pWebImpl, "Failed to get Impl");
1985 pWebImpl->SetFormDataList(pDataList);
1992 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
1994 SysAssertf(pSmartData, "Failed to request");
1996 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1997 SysAssertf(pWebImpl, "Failed to get Impl");
1999 if (pWebImpl->IsFormDataWindowVisible())
2011 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2013 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2014 SysAssertf(pPresenter && !pError, "Failed to request");
2016 bool ret = EINA_TRUE;
2020 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2022 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2026 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2035 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2037 pPresenter->EndAsyncProcess(ret);
2042 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2044 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2045 SysAssertf(pPresenter, "Failed to request");
2047 String result(pResult);
2048 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2050 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2051 _WebManager* pWebManager = _WebManager::GetInstance();
2052 if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
2054 pPresenter->EndAsyncProcess(result);
2060 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2062 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2063 SysAssertf(pImpl, "Failed to request");
2065 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2066 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2068 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2072 pWebPresenter->EndAsyncProcess(*pTotalCount);
2076 if (pImpl->GetTextSearchListener())
2078 result r = E_SUCCESS;
2082 if (*pTotalCount > 0)
2084 ordinal = pImpl->GetAsyncSearchOrdinal();
2085 pImpl->SetAsyncSearchResult(*pTotalCount);
2088 if (pImpl->GetPendingAsyncSearchCount() > 0)
2093 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2094 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2095 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2096 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2098 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2099 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2102 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2103 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2106 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2107 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2108 pEventArg.release();
2114 class _JsBridgeHashCodeProvider
2115 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2118 _JsBridgeHashCodeProvider(){}
2119 virtual ~_JsBridgeHashCodeProvider(void) {}
2122 int GetHashCode(const Tizen::Base::String& obj) const
2124 return obj.GetHashCode();
2130 //Comparer implementation
2131 class _JsBridgeComparer
2132 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2135 _JsBridgeComparer(){}
2136 virtual ~_JsBridgeComparer(void) {}
2139 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2156 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2157 : _ContainerImpl(pWeb, pCore)
2158 , __isFooterVisible(false)
2159 , __isKeypadVisible(false)
2160 , __isKeypadOpened(false)
2161 , __isLoadingErrorOccurred(false)
2162 , __isRedirectRequested(false)
2163 , __isCertificateRequested(false)
2164 , __isCertificateConfirmed(false)
2165 , __isFormDataVisible(false)
2166 , __keypadBounds(0, 0, 0, 0)
2168 , __pUserLoadingListener(null)
2169 , __pUserUiListener(null)
2170 , __pUserUiListenerF(null)
2171 , __pUserKeypadEventListener(null)
2172 , __pTextSearchListener(null)
2174 , __pJsBridgeList(null)
2175 , __pJsProvider(null)
2176 , __pJsComparer(null)
2177 , __pWebDownloadHandler(null)
2179 , __pAuthChallenge(null)
2180 , __pAuthPopup(null)
2181 , __pUserMediaConfirmPopup(null)
2182 , __pContentHandlerConfirmPopup(null)
2183 , __pProtocolHandlerConfirmPopup(null)
2184 , __pGeolocationConfirmPopup(null)
2185 , __pNotificationConfirmPopup(null)
2186 , __pScriptAlertConfirmPopup(null)
2187 , __pScriptConfirmPopup(null)
2188 , __pAppCacheConfirmPopup(null)
2189 , __pDbQuotaConfirmPopup(null)
2190 , __pLocalFsQuotaConfirmPopup(null)
2191 , __pIndexedDbQuotaConfirmPopup(null)
2192 , __pPromptPopup(null)
2193 , __pCertConfirmPopup(null)
2194 , __pSelectBox(null)
2195 , __pDatePicker(null)
2196 , __pColorPicker(null)
2197 , __pFormDataWindow(null)
2199 , __policy(WEB_DECISION_CONTINUE)
2200 , __defaultUserAgent(L"")
2201 , __pFormDataList(null)
2202 , __popupClosed(false)
2204 __textSearch.__searchAll = false;
2205 __textSearch.__searchForward = true;
2206 __textSearch.__caseSensitive = false;
2207 __textSearch.__pending = 0;
2208 __textSearch.__currentIndex = 1;
2209 __textSearch.__totalCount = -1;
2210 __textSearch.__text = L"";
2214 _WebImpl::~_WebImpl()
2216 _WebManager* pWebManager = _WebManager::GetInstance();
2217 pWebManager->RemoveWeb(reinterpret_cast< int >(this));
2219 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2220 pManagerImpl->SetDownloadListener(null);
2222 RemoveEventListenerCallback();
2223 ClearCertificateDb();
2228 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2230 result r = E_SUCCESS;
2232 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2233 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2235 _Web* pCore = _Web::CreateWebN();
2236 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2238 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2240 r = CheckConstruction(pCore, pImpl);
2241 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2243 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2244 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2246 r = pImpl->Construct();
2247 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2259 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2261 result r = E_SUCCESS;
2263 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2264 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2266 _Web* pCore = _Web::CreateWebN();
2267 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2269 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2271 r = CheckConstruction(pCore, pImpl);
2272 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2274 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2275 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2277 r = pImpl->Construct();
2278 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2290 _WebImpl::Construct(void)
2292 result r = E_SUCCESS;
2294 r = __mutex.Create();
2295 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2297 r = __textSearch.__searchQueue.Construct();
2298 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2300 r = __webNotificationList.Construct();
2301 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2303 r = InitJsBridgeList();
2304 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2307 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2309 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2310 SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2312 pManagerImpl->SetDownloadListener(this);
2314 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2315 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2317 _WebManager* pWebManager = _WebManager::GetInstance();
2318 pWebManager->AddWeb(reinterpret_cast< int >(this));
2325 _WebImpl::InitializeSetting(void)
2327 result r = E_SUCCESS;
2329 WebSetting* pWebSetting = __pWebCore->GetSetting();
2330 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2332 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2333 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2335 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2337 r = SetSetting(*pWebSetting);
2338 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2340 SetEventListenerCallback();
2347 _WebImpl::IsLayoutable(void) const
2354 _WebImpl::InitWebEvent(void)
2356 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2357 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2359 return __pWebEvent->Construct(*this);
2364 _WebImpl::GetWebEvent(void) const
2366 return __pWebEvent.get();
2371 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2373 Eina_Hash* pHttpHeader = null;
2375 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2376 if (pFieldNameList.get())
2378 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2379 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2381 int count = pFieldNameList->GetCount();
2383 for (int i = 0; i < count; i++)
2385 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2386 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2388 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2389 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2391 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2392 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2394 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2396 Eina_Bool ret = false;
2398 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2399 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2401 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2402 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2404 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2405 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2412 eina_hash_free(pHttpHeader);
2419 _WebImpl::LoadUrl(const String& url) const
2421 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2422 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2424 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2431 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2433 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2434 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2436 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2438 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2440 eina_hash_free(pHttpHeader);
2447 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2449 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2450 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2452 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2454 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2456 eina_hash_free(pHttpHeader);
2463 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2465 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2467 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2468 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2469 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2470 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2472 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2479 _WebImpl::Pause(void)
2481 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2486 _WebImpl::Resume(void)
2488 ewk_view_resume(__pWebCore->GetWebNativeNode());
2493 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2495 __pSelectBox.reset();
2497 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2499 result r = E_SUCCESS;
2501 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2502 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2504 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2505 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2507 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2508 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2510 __pSelectBox = std::move(pSelectBox);
2512 return __pSelectBox->ShowPopup();
2517 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2519 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2521 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2526 _WebImpl::ClearSelectBoxPopup(void)
2528 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2530 __pSelectBox.reset();
2537 _WebImpl::GetDatepicker(void)
2539 _InputPickerPopup* pInputPicker =null;
2542 pInputPicker = __pDatePicker.get();
2544 return pInputPicker;
2549 _WebImpl::GetColorpicker(void)
2551 _InputPickerPopup* pInputPicker =null;
2554 pInputPicker = __pColorPicker.get();
2556 return pInputPicker;
2561 _WebImpl::CanGoBack(void) const
2563 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2568 _WebImpl::CanGoForward(void) const
2570 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2575 _WebImpl::GoBack(void) const
2577 ewk_view_back(__pWebCore->GetWebNativeNode());
2582 _WebImpl::GoForward(void) const
2584 ewk_view_forward(__pWebCore->GetWebNativeNode());
2589 _WebImpl::GetUrl(void) const
2591 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2596 _WebImpl::GetTitle(void) const
2598 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2603 _WebImpl::StopLoading(void) const
2605 ewk_view_stop(__pWebCore->GetWebNativeNode());
2610 _WebImpl::Reload(void) const
2612 ewk_view_reload(__pWebCore->GetWebNativeNode());
2617 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2619 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2625 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2626 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2628 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2629 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2631 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2633 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2634 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2636 pPresenter->WaitAsyncProcess(*pResult.get());
2638 return pResult.release();
2643 _WebImpl::SetZoomLevel(float level)
2645 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);
2647 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2654 _WebImpl::GetZoomLevel(void) const
2656 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2660 const PageNavigationList*
2661 _WebImpl::GetBackForwardListN(void) const
2663 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2669 result r = E_SUCCESS;
2671 _PageNavigationListImpl* pNavigationListImpl = null;
2672 _HistoryItemImpl* pHistoryItemImpl = null;
2674 std::unique_ptr<PageNavigationList> pNavigationList;
2675 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2678 int forwardCount = 0;
2683 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2684 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2686 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2687 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2689 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2690 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2692 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2693 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2695 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2696 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2698 r = pHistoryList->Construct();
2699 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2701 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2702 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2703 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2705 for (int i = -backCount; i < forwardCount + 1; i++)
2707 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2708 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2710 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2711 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2713 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2714 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2716 url = ewk_history_item_uri_get(pEwkItem);
2717 title = ewk_history_item_title_get(pEwkItem);
2718 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2720 pHistoryItemImpl->SetHistoryItem(url, title);
2722 r = pHistoryList->Add(*pHistoryItem.get());
2723 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2724 pHistoryItem.release();
2727 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2729 ewk_history_free(pEwkHistoryList);
2731 return pNavigationList.release();
2734 ewk_history_free(pEwkHistoryList);
2741 _WebImpl::SearchText(const String& text, bool searchForward)
2743 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2749 result r = E_SUCCESS;
2751 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2755 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2758 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2759 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2761 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
2762 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
2765 pPresenter->WaitAsyncProcess(result);
2767 return static_cast < bool >(result);
2772 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2774 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2780 result r = E_SUCCESS;
2782 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2786 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2789 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2790 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2797 _WebImpl::SearchNextAsync(bool searchForward)
2799 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2805 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2806 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2807 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2809 result r = E_SUCCESS;
2811 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2813 if (!__textSearch.__caseSensitive)
2815 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2820 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2823 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2824 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2831 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2833 MutexGuard lock(__mutex);
2835 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2836 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2841 if (__textSearch.__searchAll)
2843 DisableAsyncSearch();
2845 __textSearch.__searchQueue.Enqueue(this);
2846 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2848 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2849 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2853 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2855 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2859 case SEARCH_ALL_ASYNC:
2860 __textSearch.__searchAll = true;
2861 __textSearch.__text = text;
2862 __textSearch.__searchForward = true;
2863 __textSearch.__caseSensitive = caseSensitive;
2864 __textSearch.__totalCount = -1;
2865 __textSearch.__currentIndex = 1;
2867 __textSearch.__searchQueue.Enqueue(this);
2868 __textSearch.__searchQueue.Enqueue(this);
2870 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2871 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2874 case SEARCH_NEXT_ASYNC:
2875 __textSearch.__searchForward = searchForward;
2877 CalculateAsyncSearchOrdinal();
2879 __textSearch.__searchQueue.Enqueue(this);
2881 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2893 _WebImpl::SetAsyncSearchResult(int totalCount)
2895 __textSearch.__totalCount = totalCount;
2900 _WebImpl::GetSearchPresenter(void)
2902 MutexGuard lock(__mutex);
2904 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2909 _WebImpl::GetPendingAsyncSearchCount(void) const
2911 return __textSearch.__searchQueue.GetCount();
2916 _WebImpl::CalculateAsyncSearchOrdinal(void)
2918 if (__textSearch.__searchForward)
2920 __textSearch.__currentIndex++;
2924 __textSearch.__currentIndex--;
2930 _WebImpl::GetAsyncSearchOrdinal(void) const
2932 return __textSearch.__currentIndex;
2937 _WebImpl::DisableAsyncSearch(void)
2939 __textSearch.__searchAll = false;
2944 _WebImpl::SetSetting(const WebSetting& setting)
2946 if (__pWebCore->GetWebNativeNode())
2948 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2949 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2950 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2952 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2953 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2955 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2957 switch (setting.GetCacheControl())
2959 case WEB_CACHE_VALIDATED:
2960 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2963 case WEB_CACHE_IGNORE:
2964 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2971 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2973 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2977 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2980 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2982 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2984 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2986 if (__defaultUserAgent != setting.GetUserAgent())
2988 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2989 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2991 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2994 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2996 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2998 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3000 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3003 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3005 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3006 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3007 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3008 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3009 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3010 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3011 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3012 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3013 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3014 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3015 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3016 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3017 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3024 _WebImpl::GetSetting(void) const
3026 return *__pWebCore->GetSetting();
3030 const HitElementResult*
3031 _WebImpl::GetElementByPointN(const Point& point) const
3033 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3037 const HitElementResult*
3038 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3040 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3046 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));
3048 result r = E_SUCCESS;
3050 _HitElementResultImpl* pHitElementResultImpl = null;
3052 std::unique_ptr<HitElementResult> pHitElementResult;
3053 std::unique_ptr<Bitmap> pImage;
3054 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3056 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3058 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3059 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3061 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3062 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3063 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3064 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3065 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3067 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3069 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3070 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3072 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3073 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3075 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3081 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3082 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3083 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3084 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3086 r = buf.Construct(imageLength);
3087 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3089 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3090 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3094 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3095 // webkit support types such as ico and vp8 additionally
3096 if (strcmp(pExtension, "gif") == 0)
3098 format = IMG_FORMAT_GIF;
3100 else if (strcmp(pExtension, "jpg") == 0)
3102 format = IMG_FORMAT_JPG;
3104 else if (strcmp(pExtension, "png") == 0)
3106 format = IMG_FORMAT_PNG;
3108 else if (strcmp(pExtension, "bmp") == 0)
3110 format = IMG_FORMAT_BMP;
3114 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3118 r = image.Construct();
3119 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3121 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3122 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3127 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3128 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3130 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3131 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3133 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3134 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3137 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3139 ewk_hit_test_free(pEwkHitTest);
3141 return pHitElementResult.release();
3144 ewk_hit_test_free(pEwkHitTest);
3151 _WebImpl::IsLoading(void) const
3153 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3155 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3167 _WebImpl::GetTextFromBlock(void) const
3169 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3174 _WebImpl::IsPrivateBrowsingEnabled(void) const
3176 if (__pWebCore->GetWebNativeNode() == null)
3178 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3181 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3182 SysAssertf(pSettings, "Failed to get webkit instance.");
3184 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3189 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3191 if (__pWebCore->GetWebNativeNode() == null)
3193 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3197 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3198 SysAssertf(pSettings, "Failed to get webkit instance.");
3200 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3205 _WebImpl::ClearHistory(void)
3207 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3212 _WebImpl::ClearCache(void)
3214 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3216 ewk_context_cache_clear(pContext);
3221 _WebImpl::ClearCookie(void)
3223 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3224 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3226 ewk_cookie_manager_cookies_clear(pCookieManager);
3231 _WebImpl::ClearFormData(void)
3233 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3235 ewk_context_form_candidate_data_clear(pContext);
3240 _WebImpl::ClearLoginFormData(void)
3242 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3244 ewk_context_form_password_data_clear(pContext);
3249 _WebImpl::IsCookieEnabled(void) const
3251 if (__pWebCore->GetWebNativeNode() == null)
3253 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3256 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3257 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3258 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3260 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
3261 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3263 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
3265 bool result = false;
3266 pPresenter->WaitAsyncProcess(result);
3273 _WebImpl::SetCookieEnabled(bool enable)
3275 if (__pWebCore->GetWebNativeNode() == null)
3277 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3282 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3283 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3284 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3288 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3292 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3293 ewk_cookie_manager_cookies_clear(pCookieManager);
3299 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3301 result r = E_SUCCESS;
3303 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3304 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3307 String fileExtension = File::GetFileExtension(filePath);
3308 int pathLength = filePath.GetLength();
3311 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3313 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3314 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3315 r = filePath.SubString(0, index + 1, dirPath);
3316 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3318 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3319 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3323 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3325 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3329 Evas_Coord contentsWidth;
3330 Evas_Coord contentsHeight;
3332 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3333 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3341 _WebImpl::IsMimeSupported(const String& mime) const
3343 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3344 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3346 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3351 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3353 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3358 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3360 __pUserUiListener = pUiEventListener;
3365 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3367 __pUserUiListenerF = pUiEventListener;
3372 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3374 __pUserKeypadEventListener = pKeypadEventListener;
3379 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3381 if (__pWebDownloadHandler.get() == null)
3383 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3384 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3387 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3388 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3393 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3395 __pTextSearchListener = pTextSearchListener;
3400 _WebImpl::SetScrollEnabled(bool enable)
3402 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3407 _WebImpl::IsScrollEnabled(void) const
3409 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3414 _WebImpl::InitJsBridgeList(void)
3416 result r = E_SUCCESS;
3418 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3419 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3421 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3422 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3424 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3425 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3427 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3428 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3430 __pJsBridgeList = std::move(pJsBridgeList);
3437 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3439 result r = E_SUCCESS;
3441 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3442 String key(pJsBridge->GetName());
3444 r = __pJsBridgeList->Add(key, pJsBridge);
3445 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3452 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3454 result r = E_SUCCESS;
3456 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3457 String key(pJsBridge->GetName());
3459 r = __pJsBridgeList->Remove(key);
3460 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3467 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3469 result r = E_SUCCESS;
3471 IJsonValue* pJsonValue = null;
3472 IJavaScriptBridge* pJsBridge = null;
3474 String key(L"name");
3476 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3477 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));
3479 r = pJsonObject->GetValue(&key, pJsonValue);
3480 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3482 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3483 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3485 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3486 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3493 _WebImpl::GetLoadingListener(void) const
3495 return __pUserLoadingListener;
3499 IWebUiEventListener*
3500 _WebImpl::GetUiEventListener(void) const
3502 return __pUserUiListener;
3506 IWebUiEventListenerF*
3507 _WebImpl::GetUiEventListenerF(void) const
3509 return __pUserUiListenerF;
3513 IWebKeypadEventListener*
3514 _WebImpl::GetWebKeypadEventListener(void) const
3516 return __pUserKeypadEventListener;
3520 ITextSearchListener*
3521 _WebImpl::GetTextSearchListener(void) const
3523 return __pTextSearchListener;
3528 _WebImpl::SetEventListenerCallback(void) const
3530 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3533 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3534 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3536 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3537 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3539 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3540 SysAssertf(pSmartData, "Failed to request");
3542 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3543 SysAssertf(pSmart, "Failed to request");
3545 pSmart->popup_menu_show = OnSelectBoxRequested;
3546 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3547 pSmart->popup_menu_hide = OnSelectBoxClosed;
3548 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3550 pSmart->input_picker_show = OnDatePickerProviderRequested;
3551 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3552 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3554 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3555 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3556 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3557 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3559 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3561 // add loading event callbacks for ILoadingListener
3562 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3563 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3565 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3566 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3567 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3568 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3569 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3570 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3571 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3572 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3574 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3576 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3578 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3579 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3580 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3582 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3583 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3585 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3587 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3588 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3589 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3591 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3593 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3594 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3595 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3597 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3598 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3599 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3601 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3602 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3603 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3605 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3606 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3607 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3608 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3610 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3611 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3613 evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
3615 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
3616 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
3618 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3619 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3620 SysAssertf(pContext, "Failed to get webkit instance.");
3621 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3622 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3624 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3625 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3626 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3627 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3629 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3635 _WebImpl::RemoveEventListenerCallback(void) const
3637 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3640 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3641 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3643 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3644 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3646 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3647 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3649 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3650 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3651 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3652 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3653 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3654 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3655 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3656 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3658 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3660 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3662 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3663 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3664 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3666 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3667 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3669 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3671 ewk_view_javascript_alert_callback_set(null, null, null);
3672 ewk_view_javascript_prompt_callback_set(null, null, null);
3673 ewk_view_javascript_confirm_callback_set(null, null, null);
3675 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3677 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3678 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3679 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3681 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3682 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3683 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3684 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3685 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3686 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3688 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3689 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3690 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3692 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3694 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3695 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3697 evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
3699 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
3700 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
3702 ewk_view_open_panel_callback_set(null, null, null);
3703 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3704 SysAssertf(pContext, "Failed to get webkit instance.");
3705 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3707 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3708 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3709 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3710 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3712 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3718 _WebImpl::ClearCertificateDb(void)
3720 result r = E_SUCCESS;
3722 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3723 String table(CERTIFICATE_TABLE_NAME);
3726 r = db.Construct(certificatePath, "r+", null);
3727 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3729 db.BeginTransaction();
3731 r = db.ExecuteSql(L"Delete From " + table, true);
3732 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3734 db.CommitTransaction();
3739 db.RollbackTransaction();
3744 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3746 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3751 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3753 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3754 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
3755 if (pSmartData && pSmartData->api)
3757 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3759 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3762 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3764 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3765 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3767 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3769 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3771 ewk_view_command_execute(pView, "SelectWord", 0);
3775 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3776 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3779 ewk_view_command_execute(pView, "SelectWord", 0);
3785 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3787 evas_object_smart_callback_call(pView, "text,selected", NULL);
3794 _WebImpl::ReleaseBlock(void)
3796 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3801 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3803 FloatPoint tempStartPoint;
3804 FloatPoint tempEndPoint;
3806 GetBlockRange(tempStartPoint, tempEndPoint);
3808 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3809 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3814 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3816 Eina_Rectangle leftHandle;
3817 Eina_Rectangle rightHandle;
3819 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3820 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3822 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3824 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3825 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3826 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3827 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3829 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3831 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3832 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3838 _WebImpl::GetFaviconN(void) const
3840 result r = E_SUCCESS;
3842 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3843 Ewk_Context* pContext = ewk_view_context_get(pView);
3844 const char* pUrl = ewk_view_url_get(pView);
3845 Evas* pEvas = evas_object_evas_get(pView);
3847 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3853 Tizen::Graphics::BufferInfo bufferInfo;
3855 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3856 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3858 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3859 Tizen::Base::ByteBuffer byteBuffer;
3861 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3862 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3864 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3865 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3867 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3868 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3870 return pImage.release();
3876 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3878 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3883 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3885 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3890 _WebImpl::GetScrollPosition(void) const
3894 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3901 _WebImpl::GetPageSize(void) const
3903 Evas_Coord width = 0;
3904 Evas_Coord height = 0;
3906 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3908 Dimension size(static_cast< int >(width), static_cast< int >(height));
3915 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
3917 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3919 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3920 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3922 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
3924 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
3931 _WebImpl::RemoveHttpHeaderField(const String& name)
3933 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3935 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3936 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3938 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
3945 _WebImpl::SetLoadingErrorOccurred(bool arg)
3947 __isLoadingErrorOccurred = arg;
3952 _WebImpl::IsLoadingErrorOccurred(void) const
3954 return __isLoadingErrorOccurred;
3959 _WebImpl::SetRedirectRequested(bool arg)
3961 __isRedirectRequested = arg;
3966 _WebImpl::IsRedirectRequested(void) const
3968 return __isRedirectRequested;
3973 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3980 _WebImpl::GetPolicyDecision(void) const
3987 _WebImpl::SetCertificateRequested(bool arg)
3989 __isCertificateRequested = arg;
3994 _WebImpl::IsCertificateRequested(void) const
3996 return __isCertificateRequested;
4001 _WebImpl::SetCertificateConfirmed(bool arg)
4003 __isCertificateConfirmed = arg;
4008 _WebImpl::IsCertificateConfirmed(void) const
4010 return __isCertificateConfirmed;
4015 _WebImpl::SetFullScreenKeypad(void)
4017 result r = E_SUCCESS;
4019 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4020 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4022 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4023 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4025 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4026 pKeypad->SetText(text);
4028 r = pKeypad->SetShowState(true);
4029 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4031 r = pKeypad->Show();
4032 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4034 pKeypad->AddTextEventListener(*this);
4036 __pKeypad = std::move(pKeypad);
4043 _WebImpl::RemoveFullScreenKeypad(void)
4045 __pKeypad->RemoveTextEventListener(*this);
4052 _WebImpl::IsFooterVisible(void) const
4054 return __isFooterVisible;
4059 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4061 __isFooterVisible = isFooterVisible;
4066 _WebImpl::IsKeypadVisible(void) const
4068 return __isKeypadVisible;
4073 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4075 __isKeypadVisible = isKeypadVisible;
4080 _WebImpl::IsKeypadOpened(void) const
4082 return __isKeypadOpened;
4086 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4088 __isKeypadOpened = isKeypadOpened;
4093 _WebImpl::GetPreviousKeypadBounds(void) const
4095 return __keypadBounds;
4100 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4102 __keypadBounds = bounds;
4107 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4109 RemoveFullScreenKeypad();
4114 _WebImpl::OnTextValueChanged(const Control& source)
4116 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4118 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4120 RemoveFullScreenKeypad();
4125 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4127 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4128 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4130 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4131 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4133 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4134 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4136 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4143 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4145 result r = E_SUCCESS;
4147 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4148 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4150 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4152 ILoadingListener* pLoadingListner = GetLoadingListener();
4153 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4155 switch (pEventArg->GetEventType())
4157 case WEB_EVENT_LOADINGLISTENER_STARTED:
4159 pLoadingListner->OnLoadingStarted();
4163 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4165 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4166 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4168 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4172 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4174 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4175 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4177 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4181 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4183 pLoadingListner->OnLoadingCanceled();
4187 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4189 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4190 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4192 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4193 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4195 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4197 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4201 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4203 pLoadingListner->OnLoadingCompleted();
4207 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4209 pLoadingListner->OnHttpAuthenticationCanceled();
4213 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4215 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4216 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4220 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4236 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4238 result r = E_SUCCESS;
4240 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4241 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4243 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4245 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4246 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4248 switch (pEventArg->GetEventType())
4250 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4252 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4253 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4255 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4259 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4261 pWebDownloadListener->OnWebDataDownloadCompleted();
4265 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4267 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4268 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4270 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4272 pWebDownloadListener->OnWebDownloadFailed(errorType);
4287 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4289 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4290 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4292 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4294 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4296 switch (pEventArg->GetEventType())
4298 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4300 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4302 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4303 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4305 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4306 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4308 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4312 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4314 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4316 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4320 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4322 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4324 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4328 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4330 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4332 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4333 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4335 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4350 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4352 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4353 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4355 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4357 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4359 switch (pEventArg->GetEventType())
4361 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4363 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4365 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4366 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4368 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4369 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4371 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4375 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4377 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4379 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4383 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4385 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4387 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4391 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4393 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4395 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4396 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4398 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4413 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4415 result r = E_SUCCESS;
4417 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4418 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4420 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4422 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4423 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4425 switch (pEventArg->GetEventType())
4427 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4429 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4430 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4432 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4433 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4435 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4450 _WebImpl::VibrationRequested(uint64_t duration)
4452 result r = E_SUCCESS;
4454 __pVibrator.reset();
4456 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4457 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4459 r = pVibrator->Construct();
4460 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4462 __pVibrator = std::move(pVibrator);
4464 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4466 r = __pVibrator->Start(&pattern, 1, 1);
4467 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4474 _WebImpl::VibrationCanceled(void)
4476 __pVibrator.reset();
4481 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4483 result r = E_SUCCESS;
4485 String host(ewk_auth_challenge_url_get(pChallenge));
4486 String realm(ewk_auth_challenge_realm_get(pChallenge));
4488 __pAuthChallenge.reset();
4490 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4491 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4493 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4494 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4496 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4497 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4499 __pAuthChallenge = std::move(pAuthChallenge);
4501 ewk_auth_challenge_suspend(pChallenge);
4502 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4504 __pAuthChallenge.release();
4508 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4509 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4517 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4519 result r = E_SUCCESS;
4521 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4522 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4524 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4525 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4527 __pAuthPopup = std::move(pAuthPopup);
4529 int modalResult = 0;
4531 r = __pAuthPopup->ShowAndWait(modalResult);
4532 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4537 __pAuthPopup.reset();
4545 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4547 result r = E_SUCCESS;
4549 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4550 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4552 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy, this);
4553 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4555 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4557 int modalResult = 0;
4559 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4560 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4562 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4564 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4568 if (__pCertConfirmPopup.get())
4570 __pCertConfirmPopup.reset();
4578 _WebImpl::ShowPromptPopup(String msg, String defVal)
4580 result r = E_SUCCESS;
4582 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4583 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4585 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
4586 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4588 __pPromptPopup = std::move(pPromptPopup);
4590 r = __pPromptPopup->ShowPopup();
4591 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4596 __pPromptPopup.reset();
4604 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4606 result r = E_SUCCESS;
4608 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4609 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4611 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg);
4612 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4614 int modalResult = 0;
4616 switch(userConfirmMode)
4618 case USER_CONTENT_HANDLER:
4620 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4622 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4623 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4625 __pContentHandlerConfirmPopup.reset();
4627 ewk_view_resume(__pWebCore->GetWebNativeNode());
4631 case USER_PROTOCOL_HANDLER:
4633 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4635 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4636 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4638 __pProtocolHandlerConfirmPopup.reset();
4640 ewk_view_resume(__pWebCore->GetWebNativeNode());
4644 case USER_CONFIRM_APP_CACHE:
4646 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4648 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4649 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4651 __pAppCacheConfirmPopup.reset();
4653 ewk_view_resume(__pWebCore->GetWebNativeNode());
4657 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4659 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4661 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4662 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4664 __pDbQuotaConfirmPopup.reset();
4666 ewk_view_resume(__pWebCore->GetWebNativeNode());
4670 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4672 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4674 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4675 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4677 __pLocalFsQuotaConfirmPopup.reset();
4679 ewk_view_resume(__pWebCore->GetWebNativeNode());
4683 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4685 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4687 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4688 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4690 __pIndexedDbQuotaConfirmPopup.reset();
4692 ewk_view_resume(__pWebCore->GetWebNativeNode());
4696 case USER_SCRIPT_CONFIRM:
4698 __pScriptConfirmPopup = std::move(pUserConfirmPopup);
4700 r = __pScriptConfirmPopup->ShowAndWait(modalResult);
4701 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4703 __pScriptConfirmPopup.reset();
4705 ewk_view_resume(__pWebCore->GetWebNativeNode());
4718 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4720 result r = E_SUCCESS;
4722 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4723 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4725 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg);
4726 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4728 switch(userConfirmMode)
4730 case USER_CONFIRM_USERMEDIA:
4732 __pUserMediaConfirmPopup.reset();
4734 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4736 r = __pUserMediaConfirmPopup->ShowPopup();
4737 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4739 __pUserMediaConfirmPopup.release();
4742 case USER_CONFIRM_GEOLOCATION:
4744 __pGeolocationConfirmPopup.reset();
4746 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4748 r = __pGeolocationConfirmPopup->ShowPopup();
4749 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4751 __pGeolocationConfirmPopup.release();
4754 case USER_CONFIRM_NOTIFICATION:
4756 __pNotificationConfirmPopup.reset();
4758 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4760 r = __pNotificationConfirmPopup->ShowPopup();
4761 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4763 __pNotificationConfirmPopup.release();
4766 case USER_SCRIPT_ALERT:
4768 __pScriptAlertConfirmPopup.reset();
4770 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4772 r = __pScriptAlertConfirmPopup->ShowPopup();
4773 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4775 __pScriptAlertConfirmPopup.release();
4790 _WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl)
4793 _FormImpl* pFormImpl = null;
4795 _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent());
4796 if (!pParentControlImpl)
4801 pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl);
4807 return GetParentFormImpl(pParentControlImpl);
4812 _WebImpl::OnFocusGained(const _ControlImpl& source)
4814 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4815 SysAssertf(pSettings, "Failed to get webkit instance.");
4816 ewk_settings_clear_text_selection_automatically_set(pSettings, true);
4818 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_TRUE);
4825 _WebImpl::OnFocusLost(const _ControlImpl& source)
4827 if(IsKeypadVisible() == true)
4829 SetKeypadOpened(true);
4831 SetKeypadVisibleState(false);
4834 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4835 SysAssertf(pSettings, "Failed to get webkit instance.");
4836 ewk_settings_clear_text_selection_automatically_set(pSettings, false);
4838 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4845 _WebImpl::HasValidNativeNode(void) const
4847 if (__pWebCore && __pWebCore->GetWebNativeNode())
4857 _WebImpl::OnPreAttachedToMainTree(void)
4859 result r = E_SUCCESS;
4861 if (IsVisible() == true)
4863 _WebManager* pWebManager = _WebManager::GetInstance();
4864 pWebManager->SetActiveWeb(this);
4867 r = __pWebCore->InitializeWebNativeNode();
4868 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4870 r = InitializeSetting();
4871 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4873 r = _ContainerImpl::OnPreAttachedToMainTree();
4874 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4881 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4887 case _CONTROL_ROTATION_0:
4890 case _CONTROL_ROTATION_90:
4893 case _CONTROL_ROTATION_180:
4896 case _CONTROL_ROTATION_270:
4902 ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree);
4907 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4909 _ContainerImpl::OnChangeLayout(orientation);
4911 if (__pColorPicker.get())
4913 __pColorPicker->ChangeLayout(orientation);
4916 HideFormDataWindow();
4918 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4919 _WebNotification* pWebNotification = null;
4921 while (pEnum->MoveNext() == E_SUCCESS)
4923 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4924 pWebNotification->OnChangeLayout();
4930 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4932 _WebManager* pWebManager = _WebManager::GetInstance();
4933 if (IsVisible() == true)
4935 pWebManager->SetActiveWeb(this);
4936 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4940 pWebManager->RemoveActiveWeb(this);
4941 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4947 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4949 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
4953 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4954 __pCertConfirmPopup.reset();
4956 case ID_PROMPT_POPUP_CLOSE:
4957 __pPromptPopup.reset();
4959 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
4960 __pUserMediaConfirmPopup.reset();
4962 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
4963 __pGeolocationConfirmPopup.reset();
4965 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
4966 __pNotificationConfirmPopup.reset();
4968 case ID_USER_SCRIPT_ALERT_CLOSE:
4969 __pScriptAlertConfirmPopup.reset();
4971 case ID_USER_SCRIPT_CONFIRM_CLOSE:
4972 __pScriptConfirmPopup.reset();
4981 _WebImpl::GetDownloadHandler(void) const
4983 return __pWebDownloadHandler.get();
4988 _WebImpl::HideColorPicker(void)
4990 __pColorPicker.reset();
4997 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4999 result r = E_SUCCESS;
5001 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
5002 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5004 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
5006 r = pColorHadler->Construct(colorVal, this);
5007 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5009 __pColorPicker = std::move(pColorHadler);
5011 r = __pColorPicker->ShowPopup();
5012 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5016 color = __pColorPicker->GetColor();
5022 __pColorPicker.reset();
5030 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
5032 result r = E_SUCCESS;
5034 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
5035 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5037 r = pInputPicker->Construct(String(inputValue), inputType, this);
5038 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5040 __pDatePicker = std::move(pInputPicker);
5042 r = __pDatePicker->ShowPopup();
5043 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5047 dateStr = __pDatePicker->GetDate();
5053 __pDatePicker.reset();
5061 _WebImpl::GetInstance(Web* pWeb)
5063 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5068 _WebImpl::GetInstance(const Web* pWeb)
5070 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5075 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5077 int checkReturn = 0;
5079 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5082 if( checkmime == true)
5084 table = CUSTOM_CONTENT_TABLE_NAME;
5088 table = CUSTOM_PROTOCOL_TABLE_NAME;
5091 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5092 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5093 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5095 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5097 result r = db.Construct(handlerPath, "r+", null);
5098 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5100 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"'"));
5101 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5105 r = pEnum->MoveNext();
5106 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5107 r = pEnum->GetIntAt(0, checkReturn);
5108 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5120 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5124 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5127 if( checkmime == true)
5129 table = CUSTOM_CONTENT_TABLE_NAME;
5133 table = CUSTOM_PROTOCOL_TABLE_NAME;
5136 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5137 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5138 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5140 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5142 result r = db.Construct(handlerPath, "r+", null);
5143 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5145 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"'"));
5146 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5150 r = pEnum->MoveNext();
5151 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5152 r = pEnum->GetIntAt(0, checkId);
5153 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5155 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5156 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5158 r = pDeleteStmt->BindInt(0, checkId);
5159 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5161 db.BeginTransaction();
5163 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5165 db.CommitTransaction();
5172 const Tizen::Base::String
5173 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5175 if (originUri == L"" || currentUri == L"")
5180 result r = E_SUCCESS;
5183 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5184 String originReplace(originUri);
5185 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5189 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5190 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5192 r = currentUri.SubString(0, found + 1, baseUri);
5193 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5195 r = db.Construct(handlerPath, "r+", null);
5196 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5198 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5199 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5203 while (pEnum->MoveNext() == E_SUCCESS)
5208 String originScheme;
5210 r = pEnum->GetStringAt(0, protocol);
5211 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5213 r = pEnum->GetStringAt(1, queryUrl);
5214 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5216 r = pEnum->GetIntAt(2, allow);
5217 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5224 String protocolScheme(protocol + L":");
5226 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5227 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5229 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5231 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5233 r = originReplace.Replace(originScheme, "");
5234 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5236 queryUrl.Replace("%s", originReplace, 0);
5237 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5249 const Tizen::Base::String
5250 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5252 if (originUri == L"" || currentUri == L"" || mime == L"")
5257 result r = E_SUCCESS;
5260 String originUrlStr = originUri;
5261 const String replaceStr = L"%s";
5263 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5264 String table(CUSTOM_CONTENT_TABLE_NAME);
5268 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5269 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5271 r = currentUri.SubString(0, found + 1, baseUri);
5272 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5274 r = db.Construct(handlerPath, "r+", null);
5275 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5277 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5281 r = pEnum->MoveNext();
5282 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5283 r = pEnum->GetIntAt(0, allow);
5284 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5285 r = pEnum->GetStringAt(1, contentUrl);
5286 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5294 if (contentUrl != L"")
5296 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5297 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5309 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5311 __pFormDataList = pFormDataList;
5316 _WebImpl::IsFormDataWindowVisible(void) const
5318 return __isFormDataVisible;
5323 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5325 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5327 if (__isFormDataVisible)
5329 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5330 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5334 __pFormDataWindow.reset();
5336 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5337 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5339 result r = pFormDataWindow->Construct(rect, this, pWebView);
5340 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5342 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5343 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5345 r = pFormDataWindow->LaunchFormDataWindow();
5346 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5348 __pFormDataWindow = std::move(pFormDataWindow);
5349 __isFormDataVisible = true;
5357 _WebImpl::HideFormDataWindow(bool delWindow)
5361 __pFormDataWindow.reset();
5364 __isFormDataVisible = false;
5369 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5371 __webNotificationList.Remove(*pWebNotification);
5376 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5378 __webNotificationList.Add(pWebNotification);
5383 _WebImpl::OnDownloadCompleted(RequestId reqId, const String &path)
5385 _ContentManagerImpl::ScanFile(path);
5389 }}} // Tizen::Web::Controls