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 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
974 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
979 ewk_policy_decision_use(pPolicy);
984 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
986 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
987 SysAssertf(pImpl, "Failed to request");
989 if (pImpl->GetLoadingListener())
991 result r = E_SUCCESS;
993 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
994 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
996 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
997 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1004 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1006 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1007 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1008 SysAssertf(pImpl, "Failed to request");
1010 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1012 if (pImpl->GetLoadingListener())
1014 result r = E_SUCCESS;
1016 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1017 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1018 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1020 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1021 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1022 pPageTitle.release();
1024 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1025 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1026 pEventArg.release();
1032 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1034 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1035 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1036 SysAssertf(pImpl, "Failed to request");
1038 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1040 if (pImpl->GetLoadingListener())
1042 result r = E_SUCCESS;
1044 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1045 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1046 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1048 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1049 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1050 pProgressPercentage.release();
1052 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1053 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1054 pEventArg.release();
1060 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1062 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1063 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1064 SysAssertf(pImpl && pPolicy, "Failed to request");
1066 result r = E_SUCCESS;
1068 _SystemResource* pSysResource = _SystemResource::GetInstance();
1069 SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
1071 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1072 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1073 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1074 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1076 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1078 String url(ewk_policy_decision_url_get(pPolicy));
1080 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1082 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1084 DecisionPolicy policy;
1085 HttpHeader httpHeader;
1087 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1089 pImpl->SetRedirectRequested(true);
1093 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1094 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1096 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1097 pImpl->SetPolicyDecision(policy);
1100 switch (pImpl->GetPolicyDecision())
1102 case WEB_DECISION_CONTINUE:
1104 String currentUrl(pImpl->GetUrl());
1105 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1106 if (redirectUrl != L"")
1108 pImpl->LoadUrl(redirectUrl);
1109 ewk_policy_decision_ignore(pPolicy);
1114 if (pImpl->IsMimeSupported(mime) || mime == L"")
1121 ewk_policy_decision_ignore(pPolicy);
1123 String operationId(L"http://tizen.org/appcontrol/operation/view");
1125 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1126 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1128 if (r == E_OBJ_NOT_FOUND)
1130 _SelectBox* pSelectBox = new (std::nothrow) _SelectBox;
1131 SysTryReturnVoidResult(NID_WEB_CTRL, pSelectBox, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1133 r = pSelectBox->Construct(false, L"Select application", 1, null, url);
1134 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1136 pSelectBox->AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1137 r = pSelectBox->ShowPopup();
1138 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1145 case WEB_DECISION_DOWNLOAD:
1147 ewk_policy_decision_ignore(pPolicy);
1149 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1150 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1152 Ewk_Context* pContext = ewk_view_context_get(pView);
1153 SysAssertf(pContext, "Failed to get webkit instance.");
1155 pDownloadHandler->StartDownload(pUrl);
1159 case WEB_DECISION_IGNORE:
1161 ewk_policy_decision_ignore(pPolicy);
1171 ewk_policy_decision_use(pPolicy);
1176 ewk_policy_decision_ignore(pPolicy);
1181 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1183 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1184 SysAssertf(pImpl, "Failed to request");
1186 if (pImpl->IsRedirectRequested())
1188 pImpl->SetRedirectRequested(false);
1191 if (pImpl->IsLoadingErrorOccurred())
1193 pImpl->SetLoadingErrorOccurred(false);
1194 evas_object_smart_callback_call(pView, "load,finished", NULL);
1200 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1202 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1203 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1204 SysAssertf(pImpl && pErrorData, "Failed to request");
1206 int code = ewk_error_code_get(pErrorData);
1207 const char* pDescription = ewk_error_description_get(pErrorData);
1209 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1213 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1214 pImpl->SetLoadingErrorOccurred(true);
1217 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1218 evas_object_smart_callback_call(pView, "load,finished", NULL);
1221 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1222 pImpl->SetLoadingErrorOccurred(true);
1223 evas_object_smart_callback_call(pView, "load,stop", NULL);
1227 pImpl->SetLoadingErrorOccurred(true);
1228 if (pImpl->GetLoadingListener())
1230 result r = E_SUCCESS;
1232 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1233 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1241 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1243 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1244 SysAssertf(pImpl, "Failed to request");
1246 if (pImpl->GetLoadingListener())
1248 result r = E_SUCCESS;
1250 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1251 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1253 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1254 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1255 pEventArg.release();
1262 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1264 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1265 SysAssertf(pImpl, "Failed to request");
1267 if (pImpl->GetLoadingListener())
1269 result r = E_SUCCESS;
1271 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1272 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1274 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1275 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1276 pEventArg.release();
1283 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1285 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1286 SysAssertf(pImpl, "Failed to request");
1288 if (pImpl->GetLoadingListener())
1290 result r = E_SUCCESS;
1292 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1293 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1295 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1296 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1297 pEventArg.release();
1304 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1306 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1307 SysAssertf(pUrl && pImpl != null, "Failed to request");
1309 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1314 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1316 result r = E_SUCCESS;
1318 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1319 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1321 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1322 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1323 pEventArg.release();
1330 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1332 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1333 SysAssertf(pImpl, "Failed to request");
1335 if (pImpl->GetUiEventListener())
1337 result r = E_SUCCESS;
1339 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1340 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1342 if (pImpl->GetUiEventListenerF())
1344 result r = E_SUCCESS;
1346 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1347 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1353 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1355 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1356 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1357 SysAssertf(pParentImpl && pChildView, "Failed to request");
1359 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1360 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1361 if (pUserUiListener)
1363 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1366 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1367 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1369 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1370 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1373 if (pUserUiListenerF)
1375 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1378 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1379 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1381 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1382 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1389 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1391 result r = E_SUCCESS;
1393 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1394 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1396 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1397 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1398 pEventArg.release();
1405 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1407 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1408 SysAssertf(pChildImpl, "Failed to request");
1410 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1411 if (pParentImpl == null)
1416 if (pParentImpl->GetUiEventListener())
1418 result r = E_SUCCESS;
1420 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1421 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1423 if (pParentImpl->GetUiEventListenerF())
1425 result r = E_SUCCESS;
1427 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1428 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1434 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1436 result r = E_SUCCESS;
1438 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1439 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1440 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1442 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1443 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1444 pPreventTrigger.release();
1446 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1447 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1448 pEventArg.release();
1455 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1457 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1458 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1459 SysAssertf(pImpl && pTrigger, "Failed to request");
1461 if (pImpl->GetUiEventListener())
1463 result r = E_SUCCESS;
1465 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1466 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1468 if (pImpl->GetUiEventListenerF())
1470 result r = E_SUCCESS;
1472 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1473 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1479 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1481 result r = E_SUCCESS;
1483 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1484 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1485 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1487 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1489 if ((endPoint->x != 0) && (endPoint->y != 0))
1491 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1492 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1494 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1495 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1496 startPoint.release();
1498 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1499 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1502 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1503 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1504 pEventArg.release();
1512 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1514 result r = E_SUCCESS;
1516 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1517 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1519 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1521 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1523 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1525 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1526 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1528 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1529 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1530 startPoint.release();
1532 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1533 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1536 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1537 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1538 pEventArg.release();
1546 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1548 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1549 SysAssertf(pImpl, "Failed to request");
1551 if (pImpl->GetUiEventListener())
1553 result r = E_SUCCESS;
1555 r = FireWebPageBlockSelectedEvent(pImpl);
1556 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1558 if (pImpl->GetUiEventListenerF())
1560 result r = E_SUCCESS;
1562 r = FireWebPageBlockSelectedEventF(pImpl);
1563 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1569 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1571 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1572 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1573 SysAssertf(pImpl && pJsonText, "Failed to request");
1575 result r = E_SUCCESS;
1577 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1579 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1580 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1582 r = pEventArg->Construct(pJsonText);
1583 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1585 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1586 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1587 pEventArg.release();
1592 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1594 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1595 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1596 SysAssertf(pImpl && pEinaRect, "Failed to request");
1598 if (pImpl->IsVisible() == false)
1600 evas_object_focus_set(pView, EINA_FALSE);
1603 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1605 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1606 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1608 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1610 if (rect.height == 0)
1615 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1618 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1620 if (pFormImpl->HasFooter())
1622 pFormImpl->GetCore().SetKeypadShowState(true);
1627 if (pImpl->GetWebKeypadEventListener())
1629 if (pImpl->IsKeypadVisible() == true)
1631 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1633 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1638 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1641 pImpl->SetKeypadVisibleState(true);
1642 pImpl->SetPreviousKeypadBounds(rect);
1646 result r = pImpl->SetFullScreenKeypad();
1647 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1653 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1655 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1656 SysAssertf(pImpl, "Failed to request");
1658 if (pImpl->GetWebKeypadEventListener())
1660 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1666 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1668 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1669 SysAssertf(pImpl, "Failed to request");
1671 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1674 pFormImpl->DeflateClientRectHeight(0);
1676 if (pFormImpl->HasFooter())
1678 pFormImpl->GetCore().SetKeypadShowState(false);
1683 if (pImpl->GetWebKeypadEventListener())
1685 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1688 pImpl->SetKeypadVisibleState(false);
1693 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1695 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1696 SysAssertf(pImpl, "Failed to request");
1698 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true && pImpl->IsFocused() == true)
1700 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1701 SysAssertf(pWebCore, "Failed to get Web core object");
1703 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1705 pImpl->SetKeypadVisibleState(true);
1711 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1713 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1714 SysAssertf(pImpl, "Failed to request");
1716 if (pImpl->IsKeypadOpened() == true)
1718 pImpl->SetKeypadOpened(false);
1724 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1726 SysAssertf(pSmartData, "invalid smartdata");
1727 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1728 SysAssertf(pWebImpl, "Failed to get Impl");
1730 result r = E_SUCCESS;
1732 if (pWebImpl->GetColorpicker())
1739 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1740 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1742 byte r1, g1, b1, a1;
1743 color.GetColorComponents(r1, g1, b1, a1);
1744 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1751 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1753 SysAssertf(pSmartData, "invalid smartdata");
1755 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1756 SysAssertf(pWebImpl, "Failed to get Impl");
1758 return pWebImpl->HideColorPicker();
1763 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1765 SysAssertf(pSmartData, "Failed to request");
1766 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1767 SysAssertf(pWebImpl, "Failed to get Impl");
1769 result r = E_SUCCESS;
1771 if (pWebImpl->GetDatepicker())
1773 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1780 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1781 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1783 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1784 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1786 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1793 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1795 SysAssertf(pSmartData, "Failed to request");
1797 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1798 SysAssertf(pWebImpl, "Failed to get Impl");
1800 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1801 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1808 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1810 SysAssertf(pSmartData, "Failed to request");
1812 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1813 SysAssertf(pWebImpl, "Failed to get Impl");
1815 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1816 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1823 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1825 SysAssertf(pSmartData, "invalid smartdata");
1827 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1828 SysAssertf(pWebImpl, "Failed to get Impl");
1830 result r = pWebImpl->ClearSelectBoxPopup();
1831 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1838 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1840 SysAssertf(pSmartData, "invalid smartdata");
1842 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1843 SysAssertf(pWebImpl, "Failed to get Impl");
1845 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1846 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1853 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1855 SysAssertf(pSmartData, "Failed to request");
1857 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1858 SysAssertf(pWebImpl, "Failed to get Impl");
1860 Rectangle windowRect(x, y, w, h);
1861 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1862 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1869 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
1871 SysAssertf(pSmartData, "Failed to request");
1873 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1874 SysAssertf(pWebImpl, "Failed to get Impl");
1876 if (pWebImpl->IsFormDataWindowVisible())
1878 pWebImpl->HideFormDataWindow();
1886 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
1888 SysAssertf(pSmartData, "Failed to request");
1890 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1891 SysAssertf(pWebImpl, "Failed to get Impl");
1893 pWebImpl->SetFormDataList(pDataList);
1900 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
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 if (pWebImpl->IsFormDataWindowVisible())
1919 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1921 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1922 SysAssertf(pPresenter && !pError, "Failed to request");
1924 bool ret = EINA_TRUE;
1928 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1930 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1934 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1943 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1945 pPresenter->EndAsyncProcess(ret);
1950 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1952 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1953 SysAssertf(pPresenter, "Failed to request");
1955 String result(pResult);
1956 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1958 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
1959 _WebManager* pWebManager = _WebManager::GetInstance();
1960 if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
1962 pPresenter->EndAsyncProcess(result);
1968 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
1970 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1971 SysAssertf(pImpl, "Failed to request");
1973 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
1974 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
1976 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
1980 pWebPresenter->EndAsyncProcess(*pTotalCount);
1984 if (pImpl->GetTextSearchListener())
1986 result r = E_SUCCESS;
1990 if (*pTotalCount > 0)
1992 ordinal = pImpl->GetAsyncSearchOrdinal();
1993 pImpl->SetAsyncSearchResult(*pTotalCount);
1996 if (pImpl->GetPendingAsyncSearchCount() > 0)
2001 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2002 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2003 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2004 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2006 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2007 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2010 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2011 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2014 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2015 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2016 pEventArg.release();
2022 class _JsBridgeHashCodeProvider
2023 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2026 _JsBridgeHashCodeProvider(){}
2027 virtual ~_JsBridgeHashCodeProvider(void) {}
2030 int GetHashCode(const Tizen::Base::String& obj) const
2032 return obj.GetHashCode();
2038 //Comparer implementation
2039 class _JsBridgeComparer
2040 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2043 _JsBridgeComparer(){}
2044 virtual ~_JsBridgeComparer(void) {}
2047 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2064 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2065 : _ContainerImpl(pWeb, pCore)
2066 , __isFooterVisible(false)
2067 , __isKeypadVisible(false)
2068 , __isKeypadOpened(false)
2069 , __isLoadingErrorOccurred(false)
2070 , __isRedirectRequested(false)
2071 , __isCertificateRequested(false)
2072 , __isCertificateConfirmed(false)
2073 , __isFormDataVisible(false)
2074 , __keypadBounds(0, 0, 0, 0)
2076 , __pUserLoadingListener(null)
2077 , __pUserUiListener(null)
2078 , __pUserUiListenerF(null)
2079 , __pUserKeypadEventListener(null)
2080 , __pTextSearchListener(null)
2082 , __pJsBridgeList(null)
2083 , __pJsProvider(null)
2084 , __pJsComparer(null)
2085 , __pWebDownloadHandler(null)
2087 , __pAuthChallenge(null)
2088 , __pAuthPopup(null)
2089 , __pUserMediaConfirmPopup(null)
2090 , __pContentHandlerConfirmPopup(null)
2091 , __pProtocolHandlerConfirmPopup(null)
2092 , __pGeolocationConfirmPopup(null)
2093 , __pNotificationConfirmPopup(null)
2094 , __pScriptAlertConfirmPopup(null)
2095 , __pScriptConfirmPopup(null)
2096 , __pAppCacheConfirmPopup(null)
2097 , __pDbQuotaConfirmPopup(null)
2098 , __pLocalFsQuotaConfirmPopup(null)
2099 , __pIndexedDbQuotaConfirmPopup(null)
2100 , __pPromptPopup(null)
2101 , __pCertConfirmPopup(null)
2102 , __pSelectBox(null)
2103 , __pDatePicker(null)
2104 , __pColorPicker(null)
2105 , __pFormDataWindow(null)
2107 , __policy(WEB_DECISION_CONTINUE)
2108 , __defaultUserAgent(L"")
2109 , __pFormDataList(null)
2110 , __popupClosed(false)
2112 __textSearch.__searchAll = false;
2113 __textSearch.__searchForward = true;
2114 __textSearch.__caseSensitive = false;
2115 __textSearch.__pending = 0;
2116 __textSearch.__currentIndex = 1;
2117 __textSearch.__totalCount = -1;
2118 __textSearch.__text = L"";
2122 _WebImpl::~_WebImpl()
2124 ClearCertificateDb();
2129 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2131 result r = E_SUCCESS;
2133 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2134 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2136 _Web* pCore = _Web::CreateWebN();
2137 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2139 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2141 r = CheckConstruction(pCore, pImpl);
2142 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2144 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2145 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2147 r = pImpl->Construct();
2148 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2160 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2162 result r = E_SUCCESS;
2164 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2165 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2167 _Web* pCore = _Web::CreateWebN();
2168 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2170 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2172 r = CheckConstruction(pCore, pImpl);
2173 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2175 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2176 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2178 r = pImpl->Construct();
2179 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2191 _WebImpl::Construct(void)
2193 result r = E_SUCCESS;
2195 r = __mutex.Create();
2196 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2198 r = __textSearch.__searchQueue.Construct();
2199 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2201 r = __webNotificationList.Construct();
2202 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2204 r = InitJsBridgeList();
2205 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2208 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2210 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2211 SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2213 pManagerImpl->SetDownloadListener(this);
2215 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2216 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2223 _WebImpl::InitializeSetting(void)
2225 result r = E_SUCCESS;
2227 WebSetting* pWebSetting = __pWebCore->GetSetting();
2228 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2230 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2231 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2233 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2235 r = SetSetting(*pWebSetting);
2236 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2238 SetEventListenerCallback();
2245 _WebImpl::IsLayoutable(void) const
2252 _WebImpl::InitWebEvent(void)
2254 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2255 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2257 return __pWebEvent->Construct(*this);
2262 _WebImpl::GetWebEvent(void) const
2264 return __pWebEvent.get();
2269 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2271 Eina_Hash* pHttpHeader = null;
2273 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2274 if (pFieldNameList.get())
2276 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2277 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2279 int count = pFieldNameList->GetCount();
2281 for (int i = 0; i < count; i++)
2283 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2284 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2286 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2287 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2289 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2290 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2292 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2294 Eina_Bool ret = false;
2296 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2297 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2299 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2300 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2302 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2303 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2310 eina_hash_free(pHttpHeader);
2317 _WebImpl::LoadUrl(const String& url) const
2319 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2320 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2322 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2329 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2331 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2332 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2334 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2336 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2338 eina_hash_free(pHttpHeader);
2345 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2347 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2348 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2350 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2352 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2354 eina_hash_free(pHttpHeader);
2361 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2363 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2365 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2366 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2367 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2368 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2370 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2377 _WebImpl::Pause(void)
2379 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2384 _WebImpl::Resume(void)
2386 ewk_view_resume(__pWebCore->GetWebNativeNode());
2391 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2393 __pSelectBox.reset();
2395 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2397 result r = E_SUCCESS;
2399 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2400 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2402 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2403 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2405 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2406 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2408 __pSelectBox = std::move(pSelectBox);
2410 return __pSelectBox->ShowPopup();
2415 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2417 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2419 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2424 _WebImpl::ClearSelectBoxPopup(void)
2426 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2428 __pSelectBox.reset();
2435 _WebImpl::GetDatepicker(void)
2437 _InputPickerPopup* pInputPicker =null;
2440 pInputPicker = __pDatePicker.get();
2442 return pInputPicker;
2447 _WebImpl::GetColorpicker(void)
2449 _InputPickerPopup* pInputPicker =null;
2452 pInputPicker = __pColorPicker.get();
2454 return pInputPicker;
2459 _WebImpl::CanGoBack(void) const
2461 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2466 _WebImpl::CanGoForward(void) const
2468 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2473 _WebImpl::GoBack(void) const
2475 ewk_view_back(__pWebCore->GetWebNativeNode());
2480 _WebImpl::GoForward(void) const
2482 ewk_view_forward(__pWebCore->GetWebNativeNode());
2487 _WebImpl::GetUrl(void) const
2489 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2494 _WebImpl::GetTitle(void) const
2496 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2501 _WebImpl::StopLoading(void) const
2503 ewk_view_stop(__pWebCore->GetWebNativeNode());
2508 _WebImpl::Reload(void) const
2510 ewk_view_reload(__pWebCore->GetWebNativeNode());
2515 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2517 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2523 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2524 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2526 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2527 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2529 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2531 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2532 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2534 pPresenter->WaitAsyncProcess(*pResult.get());
2536 return pResult.release();
2541 _WebImpl::SetZoomLevel(float level)
2543 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);
2545 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2552 _WebImpl::GetZoomLevel(void) const
2554 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2558 const PageNavigationList*
2559 _WebImpl::GetBackForwardListN(void) const
2561 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2567 result r = E_SUCCESS;
2569 _PageNavigationListImpl* pNavigationListImpl = null;
2570 _HistoryItemImpl* pHistoryItemImpl = null;
2572 std::unique_ptr<PageNavigationList> pNavigationList;
2573 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2576 int forwardCount = 0;
2581 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2582 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2584 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2585 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2587 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2588 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2590 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2591 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2593 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2594 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2596 r = pHistoryList->Construct();
2597 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2599 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2600 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2601 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2603 for (int i = -backCount; i < forwardCount + 1; i++)
2605 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2606 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2608 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2609 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2611 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2612 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2614 url = ewk_history_item_uri_get(pEwkItem);
2615 title = ewk_history_item_title_get(pEwkItem);
2616 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2618 pHistoryItemImpl->SetHistoryItem(url, title);
2620 r = pHistoryList->Add(*pHistoryItem.get());
2621 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2622 pHistoryItem.release();
2625 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2627 ewk_history_free(pEwkHistoryList);
2629 return pNavigationList.release();
2632 ewk_history_free(pEwkHistoryList);
2639 _WebImpl::SearchText(const String& text, bool searchForward)
2641 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2647 result r = E_SUCCESS;
2649 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2653 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2656 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2657 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2659 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
2660 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
2663 pPresenter->WaitAsyncProcess(result);
2665 return static_cast < bool >(result);
2670 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2672 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2678 result r = E_SUCCESS;
2680 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2684 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2687 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2688 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2695 _WebImpl::SearchNextAsync(bool searchForward)
2697 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2703 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2704 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2705 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2707 result r = E_SUCCESS;
2709 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2711 if (!__textSearch.__caseSensitive)
2713 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2718 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2721 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2722 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2729 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2731 MutexGuard lock(__mutex);
2733 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2734 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2739 if (__textSearch.__searchAll)
2741 DisableAsyncSearch();
2743 __textSearch.__searchQueue.Enqueue(this);
2744 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2746 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2747 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2751 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2753 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2757 case SEARCH_ALL_ASYNC:
2758 __textSearch.__searchAll = true;
2759 __textSearch.__text = text;
2760 __textSearch.__searchForward = true;
2761 __textSearch.__caseSensitive = caseSensitive;
2762 __textSearch.__totalCount = -1;
2763 __textSearch.__currentIndex = 1;
2765 __textSearch.__searchQueue.Enqueue(this);
2766 __textSearch.__searchQueue.Enqueue(this);
2768 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2769 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2772 case SEARCH_NEXT_ASYNC:
2773 __textSearch.__searchForward = searchForward;
2775 CalculateAsyncSearchOrdinal();
2777 __textSearch.__searchQueue.Enqueue(this);
2779 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2791 _WebImpl::SetAsyncSearchResult(int totalCount)
2793 __textSearch.__totalCount = totalCount;
2798 _WebImpl::GetSearchPresenter(void)
2800 MutexGuard lock(__mutex);
2802 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2807 _WebImpl::GetPendingAsyncSearchCount(void) const
2809 return __textSearch.__searchQueue.GetCount();
2814 _WebImpl::CalculateAsyncSearchOrdinal(void)
2816 if (__textSearch.__searchForward)
2818 __textSearch.__currentIndex++;
2822 __textSearch.__currentIndex--;
2828 _WebImpl::GetAsyncSearchOrdinal(void) const
2830 return __textSearch.__currentIndex;
2835 _WebImpl::DisableAsyncSearch(void)
2837 __textSearch.__searchAll = false;
2842 _WebImpl::SetSetting(const WebSetting& setting)
2844 if (__pWebCore->GetWebNativeNode())
2846 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2847 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2848 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2850 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2851 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2853 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2855 switch (setting.GetCacheControl())
2857 case WEB_CACHE_VALIDATED:
2858 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2861 case WEB_CACHE_IGNORE:
2862 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2869 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2871 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2875 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2878 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2880 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2882 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2884 if (__defaultUserAgent != setting.GetUserAgent())
2886 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2887 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2889 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2892 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2894 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2896 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2898 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2901 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2903 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2904 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2905 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2906 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2907 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2908 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2909 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2910 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2911 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2912 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2913 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2914 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2915 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2922 _WebImpl::GetSetting(void) const
2924 return *__pWebCore->GetSetting();
2928 const HitElementResult*
2929 _WebImpl::GetElementByPointN(const Point& point) const
2931 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
2935 const HitElementResult*
2936 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2938 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2944 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));
2946 result r = E_SUCCESS;
2948 _HitElementResultImpl* pHitElementResultImpl = null;
2950 std::unique_ptr<HitElementResult> pHitElementResult;
2951 std::unique_ptr<Bitmap> pImage;
2952 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2954 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
2956 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2957 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2959 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2960 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2961 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2962 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2963 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2965 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2967 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2968 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2970 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2971 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2973 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
2979 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
2980 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
2981 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
2982 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
2984 r = buf.Construct(imageLength);
2985 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2987 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
2988 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2992 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
2993 // webkit support types such as ico and vp8 additionally
2994 if (strcmp(pExtension, "gif") == 0)
2996 format = IMG_FORMAT_GIF;
2998 else if (strcmp(pExtension, "jpg") == 0)
3000 format = IMG_FORMAT_JPG;
3002 else if (strcmp(pExtension, "png") == 0)
3004 format = IMG_FORMAT_PNG;
3006 else if (strcmp(pExtension, "bmp") == 0)
3008 format = IMG_FORMAT_BMP;
3012 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3016 r = image.Construct();
3017 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3019 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3020 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3025 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3026 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3028 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3029 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3031 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3032 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3035 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3037 ewk_hit_test_free(pEwkHitTest);
3039 return pHitElementResult.release();
3042 ewk_hit_test_free(pEwkHitTest);
3049 _WebImpl::IsLoading(void) const
3051 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3053 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3065 _WebImpl::GetTextFromBlock(void) const
3067 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3072 _WebImpl::IsPrivateBrowsingEnabled(void) const
3074 if (__pWebCore->GetWebNativeNode() == null)
3076 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3079 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3080 SysAssertf(pSettings, "Failed to get webkit instance.");
3082 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3087 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3089 if (__pWebCore->GetWebNativeNode() == null)
3091 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3095 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3096 SysAssertf(pSettings, "Failed to get webkit instance.");
3098 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3103 _WebImpl::ClearHistory(void)
3105 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3110 _WebImpl::ClearCache(void)
3112 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3114 ewk_context_cache_clear(pContext);
3119 _WebImpl::ClearCookie(void)
3121 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3122 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3124 ewk_cookie_manager_cookies_clear(pCookieManager);
3129 _WebImpl::ClearFormData(void)
3131 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3133 ewk_context_form_candidate_data_clear(pContext);
3138 _WebImpl::ClearLoginFormData(void)
3140 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3142 ewk_context_form_password_data_clear(pContext);
3147 _WebImpl::IsCookieEnabled(void) const
3149 if (__pWebCore->GetWebNativeNode() == null)
3151 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3154 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3155 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3156 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3158 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
3159 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3161 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
3163 bool result = false;
3164 pPresenter->WaitAsyncProcess(result);
3171 _WebImpl::SetCookieEnabled(bool enable)
3173 if (__pWebCore->GetWebNativeNode() == null)
3175 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3180 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3181 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3182 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3186 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3190 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3191 ewk_cookie_manager_cookies_clear(pCookieManager);
3197 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3199 result r = E_SUCCESS;
3201 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3202 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3205 String fileExtension = File::GetFileExtension(filePath);
3206 int pathLength = filePath.GetLength();
3209 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3211 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3212 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3213 r = filePath.SubString(0, index + 1, dirPath);
3214 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3216 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3217 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3221 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3223 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3227 Evas_Coord contentsWidth;
3228 Evas_Coord contentsHeight;
3230 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3231 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3239 _WebImpl::IsMimeSupported(const String& mime) const
3241 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3242 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3244 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3249 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3251 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3256 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3258 __pUserUiListener = pUiEventListener;
3263 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3265 __pUserUiListenerF = pUiEventListener;
3270 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3272 __pUserKeypadEventListener = pKeypadEventListener;
3277 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3279 if (__pWebDownloadHandler.get() == null)
3281 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3282 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3285 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3286 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3291 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3293 __pTextSearchListener = pTextSearchListener;
3298 _WebImpl::SetScrollEnabled(bool enable)
3300 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3305 _WebImpl::IsScrollEnabled(void) const
3307 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3312 _WebImpl::InitJsBridgeList(void)
3314 result r = E_SUCCESS;
3316 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3317 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3319 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3320 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3322 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3323 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3325 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3326 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3328 __pJsBridgeList = std::move(pJsBridgeList);
3335 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3337 result r = E_SUCCESS;
3339 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3340 String key(pJsBridge->GetName());
3342 r = __pJsBridgeList->Add(key, pJsBridge);
3343 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3350 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3352 result r = E_SUCCESS;
3354 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3355 String key(pJsBridge->GetName());
3357 r = __pJsBridgeList->Remove(key);
3358 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3365 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3367 result r = E_SUCCESS;
3369 IJsonValue* pJsonValue = null;
3370 IJavaScriptBridge* pJsBridge = null;
3372 String key(L"name");
3374 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3375 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));
3377 r = pJsonObject->GetValue(&key, pJsonValue);
3378 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3380 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3381 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3383 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3384 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3391 _WebImpl::GetLoadingListener(void) const
3393 return __pUserLoadingListener;
3397 IWebUiEventListener*
3398 _WebImpl::GetUiEventListener(void) const
3400 return __pUserUiListener;
3404 IWebUiEventListenerF*
3405 _WebImpl::GetUiEventListenerF(void) const
3407 return __pUserUiListenerF;
3411 IWebKeypadEventListener*
3412 _WebImpl::GetWebKeypadEventListener(void) const
3414 return __pUserKeypadEventListener;
3418 ITextSearchListener*
3419 _WebImpl::GetTextSearchListener(void) const
3421 return __pTextSearchListener;
3426 _WebImpl::SetEventListenerCallback(void) const
3428 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3431 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3432 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3434 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3435 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3437 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3438 SysAssertf(pSmartData, "Failed to request");
3440 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3441 SysAssertf(pSmart, "Failed to request");
3443 pSmart->popup_menu_show = OnSelectBoxRequested;
3444 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3445 pSmart->popup_menu_hide = OnSelectBoxClosed;
3446 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3448 pSmart->input_picker_show = OnDatePickerProviderRequested;
3449 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3450 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3452 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3453 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3454 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3455 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3457 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3459 // add loading event callbacks for ILoadingListener
3460 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3461 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3463 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3464 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3465 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3466 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3467 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3468 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3469 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3470 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3472 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3474 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3476 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3477 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3478 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3480 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3481 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3483 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3485 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3486 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3487 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3489 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3491 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3492 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3493 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3495 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3496 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3497 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3499 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3500 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3501 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3503 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3504 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3505 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3506 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3508 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3509 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3511 evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
3513 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
3514 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
3516 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3517 SysAssertf(pContext, "Failed to get webkit instance.");
3518 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3519 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3521 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3522 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3523 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3524 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3526 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3532 _WebImpl::RemoveEventListenerCallback(void) const
3534 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3537 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3538 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3540 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3541 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3543 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3544 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3546 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3547 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3548 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3549 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3550 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3551 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3552 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3553 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3555 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3557 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3559 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3560 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3561 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3563 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3564 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3566 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3568 ewk_view_javascript_alert_callback_set(null, null, null);
3569 ewk_view_javascript_prompt_callback_set(null, null, null);
3570 ewk_view_javascript_confirm_callback_set(null, null, null);
3572 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3574 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3575 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3576 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3578 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3579 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3580 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3581 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3582 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3583 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3585 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3586 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3587 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3589 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3591 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3592 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3594 evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
3596 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
3597 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
3599 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3600 SysAssertf(pContext, "Failed to get webkit instance.");
3601 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3603 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3604 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3605 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3606 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3608 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3614 _WebImpl::ClearCertificateDb(void)
3616 result r = E_SUCCESS;
3618 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3619 String table(CERTIFICATE_TABLE_NAME);
3622 r = db.Construct(certificatePath, "r+", null);
3623 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3625 db.BeginTransaction();
3627 r = db.ExecuteSql(L"Delete From " + table, true);
3628 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3630 db.CommitTransaction();
3635 db.RollbackTransaction();
3640 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3642 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3647 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3649 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3650 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
3651 if (pSmartData && pSmartData->api)
3653 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3655 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3658 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3660 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3661 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3663 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3665 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3667 ewk_view_command_execute(pView, "SelectWord", 0);
3671 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3672 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3675 ewk_view_command_execute(pView, "SelectWord", 0);
3681 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3683 evas_object_smart_callback_call(pView, "text,selected", NULL);
3690 _WebImpl::ReleaseBlock(void)
3692 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3697 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3699 FloatPoint tempStartPoint;
3700 FloatPoint tempEndPoint;
3702 GetBlockRange(tempStartPoint, tempEndPoint);
3704 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3705 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3710 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3712 Eina_Rectangle leftHandle;
3713 Eina_Rectangle rightHandle;
3715 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3716 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3718 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3720 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3721 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3722 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3723 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3725 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3727 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3728 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3734 _WebImpl::GetFaviconN(void) const
3736 result r = E_SUCCESS;
3738 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3739 Ewk_Context* pContext = ewk_view_context_get(pView);
3740 const char* pUrl = ewk_view_url_get(pView);
3741 Evas* pEvas = evas_object_evas_get(pView);
3743 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3749 Tizen::Graphics::BufferInfo bufferInfo;
3751 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3752 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3754 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3755 Tizen::Base::ByteBuffer byteBuffer;
3757 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3758 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3760 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3761 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3763 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3764 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3766 return pImage.release();
3772 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3774 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3779 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3781 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3786 _WebImpl::GetScrollPosition(void) const
3790 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3797 _WebImpl::GetPageSize(void) const
3799 Evas_Coord width = 0;
3800 Evas_Coord height = 0;
3802 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3804 Dimension size(static_cast< int >(width), static_cast< int >(height));
3811 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
3813 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3815 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3816 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3818 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
3820 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
3827 _WebImpl::RemoveHttpHeaderField(const String& name)
3829 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3831 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3832 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3834 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
3841 _WebImpl::SetLoadingErrorOccurred(bool arg)
3843 __isLoadingErrorOccurred = arg;
3848 _WebImpl::IsLoadingErrorOccurred(void) const
3850 return __isLoadingErrorOccurred;
3855 _WebImpl::SetRedirectRequested(bool arg)
3857 __isRedirectRequested = arg;
3862 _WebImpl::IsRedirectRequested(void) const
3864 return __isRedirectRequested;
3869 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3876 _WebImpl::GetPolicyDecision(void) const
3883 _WebImpl::SetCertificateRequested(bool arg)
3885 __isCertificateRequested = arg;
3890 _WebImpl::IsCertificateRequested(void) const
3892 return __isCertificateRequested;
3897 _WebImpl::SetCertificateConfirmed(bool arg)
3899 __isCertificateConfirmed = arg;
3904 _WebImpl::IsCertificateConfirmed(void) const
3906 return __isCertificateConfirmed;
3911 _WebImpl::SetFullScreenKeypad(void)
3913 result r = E_SUCCESS;
3915 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3916 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3918 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3919 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3921 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3922 pKeypad->SetText(text);
3924 r = pKeypad->SetShowState(true);
3925 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3927 r = pKeypad->Show();
3928 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3930 pKeypad->AddTextEventListener(*this);
3932 __pKeypad = std::move(pKeypad);
3939 _WebImpl::RemoveFullScreenKeypad(void)
3941 __pKeypad->RemoveTextEventListener(*this);
3948 _WebImpl::IsFooterVisible(void) const
3950 return __isFooterVisible;
3955 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3957 __isFooterVisible = isFooterVisible;
3962 _WebImpl::IsKeypadVisible(void) const
3964 return __isKeypadVisible;
3969 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3971 __isKeypadVisible = isKeypadVisible;
3976 _WebImpl::IsKeypadOpened(void) const
3978 return __isKeypadOpened;
3982 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
3984 __isKeypadOpened = isKeypadOpened;
3989 _WebImpl::GetPreviousKeypadBounds(void) const
3991 return __keypadBounds;
3996 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
3998 __keypadBounds = bounds;
4003 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4005 RemoveFullScreenKeypad();
4010 _WebImpl::OnTextValueChanged(const Control& source)
4012 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4014 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4016 RemoveFullScreenKeypad();
4021 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4023 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4024 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4026 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4027 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4029 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4030 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4032 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4039 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4041 result r = E_SUCCESS;
4043 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4044 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4046 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4048 ILoadingListener* pLoadingListner = GetLoadingListener();
4049 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4051 switch (pEventArg->GetEventType())
4053 case WEB_EVENT_LOADINGLISTENER_STARTED:
4055 pLoadingListner->OnLoadingStarted();
4059 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4061 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4062 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4064 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4068 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4070 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4071 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4073 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4077 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4079 pLoadingListner->OnLoadingCanceled();
4083 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4085 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4086 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4088 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4089 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4091 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4093 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4097 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4099 pLoadingListner->OnLoadingCompleted();
4103 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4105 pLoadingListner->OnHttpAuthenticationCanceled();
4109 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4111 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4112 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4116 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4132 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4134 result r = E_SUCCESS;
4136 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4137 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4139 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4141 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4142 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4144 switch (pEventArg->GetEventType())
4146 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4148 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4149 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4151 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4155 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4157 pWebDownloadListener->OnWebDataDownloadCompleted();
4161 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4163 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4164 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4166 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4168 pWebDownloadListener->OnWebDownloadFailed(errorType);
4183 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4185 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4186 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4188 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4190 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4192 switch (pEventArg->GetEventType())
4194 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4196 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4198 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4199 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4201 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4202 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4204 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4208 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4210 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4212 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4216 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4218 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4220 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4224 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4226 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4228 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4229 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4231 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4246 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4248 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4249 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4251 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4253 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4255 switch (pEventArg->GetEventType())
4257 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4259 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4261 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4262 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4264 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4265 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4267 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4271 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4273 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4275 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4279 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4281 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4283 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4287 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4289 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4291 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4292 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4294 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4309 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4311 result r = E_SUCCESS;
4313 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4314 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4316 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4318 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4319 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4321 switch (pEventArg->GetEventType())
4323 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4325 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4326 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4328 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4329 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4331 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4346 _WebImpl::VibrationRequested(uint64_t duration)
4348 result r = E_SUCCESS;
4350 __pVibrator.reset();
4352 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4353 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4355 r = pVibrator->Construct();
4356 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4358 __pVibrator = std::move(pVibrator);
4360 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4362 r = __pVibrator->Start(&pattern, 1, 1);
4363 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4370 _WebImpl::VibrationCanceled(void)
4372 __pVibrator.reset();
4377 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4379 result r = E_SUCCESS;
4381 String host(ewk_auth_challenge_url_get(pChallenge));
4382 String realm(ewk_auth_challenge_realm_get(pChallenge));
4384 __pAuthChallenge.reset();
4386 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4387 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4389 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4390 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4392 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4393 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4395 __pAuthChallenge = std::move(pAuthChallenge);
4397 ewk_auth_challenge_suspend(pChallenge);
4398 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4400 __pAuthChallenge.release();
4404 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4405 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4413 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4415 result r = E_SUCCESS;
4417 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4418 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4420 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4421 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4423 __pAuthPopup = std::move(pAuthPopup);
4425 int modalResult = 0;
4427 r = __pAuthPopup->ShowAndWait(modalResult);
4428 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4433 __pAuthPopup.reset();
4441 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4443 result r = E_SUCCESS;
4445 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4446 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4448 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy, this);
4449 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4451 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4453 int modalResult = 0;
4455 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4456 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4458 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4460 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4464 if (__pCertConfirmPopup.get())
4466 __pCertConfirmPopup.reset();
4474 _WebImpl::ShowPromptPopup(String msg, String defVal)
4476 result r = E_SUCCESS;
4478 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4479 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4481 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
4482 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4484 __pPromptPopup = std::move(pPromptPopup);
4486 r = __pPromptPopup->ShowPopup();
4487 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4492 __pPromptPopup.reset();
4500 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4502 result r = E_SUCCESS;
4504 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4505 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4507 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg);
4508 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4510 int modalResult = 0;
4512 switch(userConfirmMode)
4514 case USER_CONTENT_HANDLER:
4516 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4518 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4519 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4521 __pContentHandlerConfirmPopup.reset();
4523 ewk_view_resume(__pWebCore->GetWebNativeNode());
4527 case USER_PROTOCOL_HANDLER:
4529 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4531 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4532 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4534 __pProtocolHandlerConfirmPopup.reset();
4536 ewk_view_resume(__pWebCore->GetWebNativeNode());
4540 case USER_CONFIRM_APP_CACHE:
4542 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4544 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4545 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4547 __pAppCacheConfirmPopup.reset();
4549 ewk_view_resume(__pWebCore->GetWebNativeNode());
4553 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4555 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4557 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4558 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4560 __pDbQuotaConfirmPopup.reset();
4562 ewk_view_resume(__pWebCore->GetWebNativeNode());
4566 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4568 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4570 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4571 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4573 __pLocalFsQuotaConfirmPopup.reset();
4575 ewk_view_resume(__pWebCore->GetWebNativeNode());
4579 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4581 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4583 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4584 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4586 __pIndexedDbQuotaConfirmPopup.reset();
4588 ewk_view_resume(__pWebCore->GetWebNativeNode());
4592 case USER_SCRIPT_CONFIRM:
4594 __pScriptConfirmPopup = std::move(pUserConfirmPopup);
4596 r = __pScriptConfirmPopup->ShowAndWait(modalResult);
4597 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4599 __pScriptConfirmPopup.reset();
4601 ewk_view_resume(__pWebCore->GetWebNativeNode());
4614 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4616 result r = E_SUCCESS;
4618 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4619 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4621 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg);
4622 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4624 switch(userConfirmMode)
4626 case USER_CONFIRM_USERMEDIA:
4628 __pUserMediaConfirmPopup.reset();
4630 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4632 r = __pUserMediaConfirmPopup->ShowPopup();
4633 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4635 __pUserMediaConfirmPopup.release();
4638 case USER_CONFIRM_GEOLOCATION:
4640 __pGeolocationConfirmPopup.reset();
4642 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4644 r = __pGeolocationConfirmPopup->ShowPopup();
4645 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4647 __pGeolocationConfirmPopup.release();
4650 case USER_CONFIRM_NOTIFICATION:
4652 __pNotificationConfirmPopup.reset();
4654 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4656 r = __pNotificationConfirmPopup->ShowPopup();
4657 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4659 __pNotificationConfirmPopup.release();
4662 case USER_SCRIPT_ALERT:
4664 __pScriptAlertConfirmPopup.reset();
4666 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4668 r = __pScriptAlertConfirmPopup->ShowPopup();
4669 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4671 __pScriptAlertConfirmPopup.release();
4686 _WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl)
4689 _FormImpl* pFormImpl = null;
4691 _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent());
4692 if (!pParentControlImpl)
4697 pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl);
4703 return GetParentFormImpl(pParentControlImpl);
4708 _WebImpl::OnFocusGained(const _ControlImpl& source)
4710 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4711 SysAssertf(pSettings, "Failed to get webkit instance.");
4712 ewk_settings_clear_text_selection_automatically_set(pSettings, true);
4714 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_TRUE);
4721 _WebImpl::OnFocusLost(const _ControlImpl& source)
4723 if(IsKeypadVisible() == true)
4725 SetKeypadOpened(true);
4727 SetKeypadVisibleState(false);
4730 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4731 SysAssertf(pSettings, "Failed to get webkit instance.");
4732 ewk_settings_clear_text_selection_automatically_set(pSettings, false);
4734 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4741 _WebImpl::HasValidNativeNode(void) const
4743 if (__pWebCore && __pWebCore->GetWebNativeNode())
4753 _WebImpl::OnPreAttachedToMainTree(void)
4755 result r = E_SUCCESS;
4757 if (IsVisible() == true)
4759 _WebManager* pWebManager = _WebManager::GetInstance();
4760 pWebManager->SetActiveWeb(this);
4763 r = __pWebCore->InitializeWebNativeNode();
4764 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4766 _ControlManager* pControlManager = _ControlManager::GetInstance();
4767 SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance.");
4768 OnChangeLayout(pControlManager->GetScreenRotation());
4770 r = InitializeSetting();
4771 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4773 r = _ContainerImpl::OnPreAttachedToMainTree();
4774 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4776 _WebManager* pWebManager = _WebManager::GetInstance();
4777 pWebManager->AddWeb(reinterpret_cast< int >(this));
4784 _WebImpl::OnDetachingFromMainTree(void)
4786 _WebManager* pWebManager = _WebManager::GetInstance();
4787 pWebManager->RemoveWeb(reinterpret_cast< int >(this));
4788 pWebManager->RemoveActiveWeb(this);
4790 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
4791 pManagerImpl->SetDownloadListener(null);
4793 RemoveEventListenerCallback();
4800 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4806 case _CONTROL_ROTATION_0:
4809 case _CONTROL_ROTATION_90:
4812 case _CONTROL_ROTATION_180:
4815 case _CONTROL_ROTATION_270:
4821 ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree);
4826 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4828 _ContainerImpl::OnChangeLayout(orientation);
4830 if (__pColorPicker.get())
4832 __pColorPicker->ChangeLayout(orientation);
4835 HideFormDataWindow();
4837 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4838 _WebNotification* pWebNotification = null;
4840 while (pEnum->MoveNext() == E_SUCCESS)
4842 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4843 pWebNotification->OnChangeLayout();
4849 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4851 _WebManager* pWebManager = _WebManager::GetInstance();
4852 if (IsVisible() == true)
4854 pWebManager->SetActiveWeb(this);
4855 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4859 pWebManager->RemoveActiveWeb(this);
4860 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4866 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4868 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
4872 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4873 __pCertConfirmPopup.reset();
4875 case ID_PROMPT_POPUP_CLOSE:
4876 __pPromptPopup.reset();
4878 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
4879 __pUserMediaConfirmPopup.reset();
4881 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
4882 __pGeolocationConfirmPopup.reset();
4884 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
4885 __pNotificationConfirmPopup.reset();
4887 case ID_USER_SCRIPT_ALERT_CLOSE:
4888 __pScriptAlertConfirmPopup.reset();
4890 case ID_USER_SCRIPT_CONFIRM_CLOSE:
4891 __pScriptConfirmPopup.reset();
4900 _WebImpl::GetDownloadHandler(void) const
4902 return __pWebDownloadHandler.get();
4907 _WebImpl::HideColorPicker(void)
4909 __pColorPicker.reset();
4916 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4918 result r = E_SUCCESS;
4920 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4921 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4923 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4925 r = pColorHadler->Construct(colorVal, this);
4926 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4928 __pColorPicker = std::move(pColorHadler);
4930 r = __pColorPicker->ShowPopup();
4931 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4935 color = __pColorPicker->GetColor();
4941 __pColorPicker.reset();
4949 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4951 result r = E_SUCCESS;
4953 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4954 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4956 r = pInputPicker->Construct(String(inputValue), inputType, this);
4957 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4959 __pDatePicker = std::move(pInputPicker);
4961 r = __pDatePicker->ShowPopup();
4962 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4966 dateStr = __pDatePicker->GetDate();
4972 __pDatePicker.reset();
4980 _WebImpl::GetInstance(Web* pWeb)
4982 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4987 _WebImpl::GetInstance(const Web* pWeb)
4989 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4994 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4996 int checkReturn = 0;
4998 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5001 if( checkmime == true)
5003 table = CUSTOM_CONTENT_TABLE_NAME;
5007 table = CUSTOM_PROTOCOL_TABLE_NAME;
5010 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5011 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5012 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5014 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5016 result r = db.Construct(handlerPath, "r+", null);
5017 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5019 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"'"));
5020 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5024 r = pEnum->MoveNext();
5025 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5026 r = pEnum->GetIntAt(0, checkReturn);
5027 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5039 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5043 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5046 if( checkmime == true)
5048 table = CUSTOM_CONTENT_TABLE_NAME;
5052 table = CUSTOM_PROTOCOL_TABLE_NAME;
5055 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5056 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5057 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5059 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5061 result r = db.Construct(handlerPath, "r+", null);
5062 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5064 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"'"));
5065 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5069 r = pEnum->MoveNext();
5070 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5071 r = pEnum->GetIntAt(0, checkId);
5072 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5074 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5075 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5077 r = pDeleteStmt->BindInt(0, checkId);
5078 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5080 db.BeginTransaction();
5082 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5084 db.CommitTransaction();
5091 const Tizen::Base::String
5092 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5094 if (originUri == L"" || currentUri == L"")
5099 result r = E_SUCCESS;
5102 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5103 String originReplace(originUri);
5104 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5108 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5109 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5111 r = currentUri.SubString(0, found + 1, baseUri);
5112 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5114 r = db.Construct(handlerPath, "r+", null);
5115 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5117 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5118 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5122 while (pEnum->MoveNext() == E_SUCCESS)
5127 String originScheme;
5129 r = pEnum->GetStringAt(0, protocol);
5130 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5132 r = pEnum->GetStringAt(1, queryUrl);
5133 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5135 r = pEnum->GetIntAt(2, allow);
5136 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5143 String protocolScheme(protocol + L":");
5145 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5146 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5148 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5150 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5152 r = originReplace.Replace(originScheme, "");
5153 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5155 queryUrl.Replace("%s", originReplace, 0);
5156 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5168 const Tizen::Base::String
5169 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5171 if (originUri == L"" || currentUri == L"" || mime == L"")
5176 result r = E_SUCCESS;
5179 String originUrlStr = originUri;
5180 const String replaceStr = L"%s";
5182 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5183 String table(CUSTOM_CONTENT_TABLE_NAME);
5187 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5188 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5190 r = currentUri.SubString(0, found + 1, baseUri);
5191 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5193 r = db.Construct(handlerPath, "r+", null);
5194 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5196 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5200 r = pEnum->MoveNext();
5201 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5202 r = pEnum->GetIntAt(0, allow);
5203 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5204 r = pEnum->GetStringAt(1, contentUrl);
5205 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5213 if (contentUrl != L"")
5215 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5216 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5228 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5230 __pFormDataList = pFormDataList;
5235 _WebImpl::IsFormDataWindowVisible(void) const
5237 return __isFormDataVisible;
5242 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5244 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5246 if (__isFormDataVisible)
5248 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5249 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5253 __pFormDataWindow.reset();
5255 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5256 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5258 result r = pFormDataWindow->Construct(rect, this, pWebView);
5259 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5261 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5262 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5264 r = pFormDataWindow->LaunchFormDataWindow();
5265 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5267 __pFormDataWindow = std::move(pFormDataWindow);
5268 __isFormDataVisible = true;
5276 _WebImpl::HideFormDataWindow(bool delWindow)
5280 __pFormDataWindow.reset();
5283 __isFormDataVisible = false;
5288 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5290 __webNotificationList.Remove(*pWebNotification);
5295 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5297 __webNotificationList.Add(pWebNotification);
5302 _WebImpl::OnDownloadCompleted(RequestId reqId, const String &path)
5304 _ContentManagerImpl::ScanFile(path);
5308 }}} // Tizen::Web::Controls