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 <FGrpColor.h>
41 #include <FGrpPoint.h>
42 #include <FGrpRectangle.h>
43 #include <FIoDbEnumerator.h>
44 #include <FIoDbStatement.h>
46 #include <FMediaImage.h>
47 #include <FMediaImageTypes.h>
48 #include <FNetHttpHttpHeader.h>
49 #include <FSysVibrator.h>
50 #include <FUiControl.h>
51 #include <FUiCtrlKeypad.h>
52 #include <FWebCtrlHitElementResult.h>
53 #include <FWebCtrlITextSearchListener.h>
54 #include <FWebCtrlIWebDownloadListener.h>
55 #include <FWebCtrlIWebUiEventListener.h>
56 #include <FWebCtrlIWebUiEventListenerF.h>
57 #include <FWebCtrlIWebKeypadEventListener.h>
58 #include <FWebCtrlIJavaScriptBridge.h>
59 #include <FWebCtrlPageNavigationList.h>
60 #include <FWebCtrlAuthenticationChallenge.h>
61 #include <FWebCtrlWeb.h>
62 #include <FWebCtrlWebSetting.h>
63 #include <FWebHistoryItem.h>
64 #include <FWebJsonJsonObject.h>
65 #include <FWebJsonJsonParser.h>
66 #include <FWebJsonJsonString.h>
67 #include <FApp_AppControlImpl.h>
68 #include <FApp_AppControlManager.h>
69 #include <FApp_AppInfo.h>
70 #include <FApp_AppManagerImpl.h>
71 #include <FBase_StringConverter.h>
72 #include <FGrp_CoordinateSystem.h>
73 #include <FGrp_Screen.h>
74 #include <FIo_DatabaseImpl.h>
75 #include <FIo_NormalFile.h>
76 #include <FSys_SystemResource.h>
77 #include <FSys_VibratorImpl.h>
78 #include <FUi_Control.h>
79 #include <FUi_CoordinateSystemUtils.h>
80 #include <FUi_EcoreEvasMgr.h>
81 #include <FUi_EcoreEvas.h>
82 #include <FUi_ResourceSizeInfo.h>
83 #include <FUi_Window.h>
84 #include <FUiAnim_EflNode.h>
85 #include <FUiAnim_VisualElement.h>
86 #include <FUiCtrl_FooterImpl.h>
87 #include <FUiCtrl_FormImpl.h>
88 #include "FWeb_HistoryItemImpl.h"
89 #include "FWebCtrl_AppControlListener.h"
90 #include "FWebCtrl_AuthConfirmPopup.h"
91 #include "FWebCtrl_AuthenticationChallengeImpl.h"
92 #include "FWebCtrl_EflWebkit.h"
93 #include "FWebCtrl_FormDataWindow.h"
94 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
95 #include "FWebCtrl_HitElementResultImpl.h"
96 #include "FWebCtrl_InputPickerPopup.h"
97 #include "FWebCtrl_WebNotification.h"
98 #include "FWebCtrl_PageNavigationListImpl.h"
99 #include "FWebCtrl_PromptPopup.h"
100 #include "FWebCtrl_SelectBox.h"
101 #include "FWebCtrl_Utility.h"
102 #include "FWebCtrl_Web.h"
103 #include "FWebCtrl_WebDataHandler.h"
104 #include "FWebCtrl_WebEvent.h"
105 #include "FWebCtrl_WebEventArg.h"
106 #include "FWebCtrl_WebImpl.h"
107 #include "FWebCtrl_WebManager.h"
108 #include "FWebCtrl_WebPresenter.h"
109 #include "FWebCtrl_WebSettingImpl.h"
112 using namespace Tizen::App;
113 using namespace Tizen::Base;
114 using namespace Tizen::Base::Collection;
115 using namespace Tizen::Base::Runtime;
116 using namespace Tizen::Base::Utility;
117 using namespace Tizen::Content;
118 using namespace Tizen::Graphics;
119 using namespace Tizen::Io;
120 using namespace Tizen::Media;
121 using namespace Tizen::Net::Http;
122 using namespace Tizen::System;
123 using namespace Tizen::Ui;
124 using namespace Tizen::Ui::Animations;
125 using namespace Tizen::Ui::Controls;
126 using namespace Tizen::Web::Json;
129 namespace Tizen { namespace Web { namespace Controls
133 static const char WEB_CTRL[] = "webcontrol";
134 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
137 static const float MIN_ZOOM_LEVEL = 0.3;
138 static const float MAX_ZOOM_LEVEL = 2;
141 static const int REDIRECTION_HEADER_GROUP = 300;
144 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
147 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
148 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
149 static const int DEFAULT_LIST_ITEM_COUNT = 4;
153 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
155 result r = E_SUCCESS;
157 String key(reinterpret_cast< const char* >(pKey));
158 String value(reinterpret_cast< char* >(pValue));
160 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
162 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
163 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
170 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
172 result r = E_SUCCESS;
174 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
175 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
176 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
178 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
180 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
181 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
183 pAttrValue.release();
190 FreeCharArray(void* pData)
192 delete[] reinterpret_cast<char*>(pData);
197 ConvertErrorCode(int error)
199 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
203 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
205 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
207 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
209 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
211 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
213 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
215 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
217 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
219 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
221 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
223 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
225 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
227 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
229 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
230 errorCode = WEB_NO_CONNECTION;
233 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
235 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
236 errorCode = WEB_BAD_URL;
239 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
240 errorCode = WEB_FILE_ACCESS_FAILED;
243 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
244 errorCode = WEB_REQUEST_TIMEOUT;
247 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
248 errorCode = WEB_MIME_NOT_SUPPORTED;
251 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
252 errorCode = WEB_OUT_OF_MEMORY;
255 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
256 errorCode = WEB_REQUEST_MAX_EXCEEDED;
259 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
261 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
263 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
265 case EWK_ERROR_NETWORK_STATUS_OK:
267 case EWK_ERROR_NETWORK_STATUS_CREATED:
269 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
271 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
273 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
275 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
277 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
279 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
281 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
283 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
285 case EWK_ERROR_NETWORK_STATUS_FOUND:
287 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
289 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
291 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
293 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
295 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
296 errorCode = WEB_HTTP_RESPONSE;
299 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
300 errorCode = WEB_INVALID_CERTIFICATE;
304 errorCode = WEB_ERROR_UNKNOWN;
313 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
315 result r = E_SUCCESS;
317 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
318 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
319 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
320 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
322 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
323 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
324 pErrorCode.release();
326 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
327 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
328 pErrorDescription.release();
330 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
331 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
339 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
341 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
343 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
344 String msg(pMessage);
346 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
347 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
351 ewk_view_javascript_alert_reply(pView);
357 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
359 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
361 result r = E_SUCCESS;
362 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
363 String msg(pMessage);
365 r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_CONFIRM, pView, msg);
366 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
370 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
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 bool* pIsHandleNeeded = reinterpret_cast< bool* >(pEventInfo);
833 SysAssertf(pImpl, "Failed to request");
835 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
836 SysAssertf(pWebCore, "Failed to get Web core object");
838 if (pIsHandleNeeded && *pIsHandleNeeded)
840 pWebCore->SetFullScreenEntered(true);
846 OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
848 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
849 SysAssertf(pImpl, "Failed to request");
851 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
852 SysAssertf(pWebCore, "Failed to get Web core object");
854 pWebCore->SetFullScreenEntered(false);
859 OnFocusDownRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
861 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
862 SysAssertf(pImpl, "Failed to request");
864 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
865 pWebCore->SetFocusEnd(true);
870 OnFocusUpRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
872 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
873 SysAssertf(pImpl, "Failed to request");
875 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
876 pWebCore->SetFocusEnd(true);
881 OnVibrationRequested(uint64_t duration, void* pUserData)
883 result r = E_SUCCESS;
885 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
886 SysAssertf(pImpl, "Failed to request");
888 r = pImpl->VibrationRequested(duration);
889 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
894 OnVibrationCanceled(void* pUserData)
896 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
897 SysAssertf(pImpl, "Failed to request");
899 pImpl->VibrationCanceled();
904 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
906 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
907 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
908 SysAssertf(pImpl && pPolicy, "Failed to request");
910 String url(ewk_policy_decision_url_get(pPolicy));
911 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
913 if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
914 && !pImpl->IsRedirectRequested())
916 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
917 SysAssertf(pWebCore, "Failed to get Web core object");
919 pWebCore->SetFullScreenEntered(false);
921 pImpl->SetCertificateRequested(false);
923 if (pImpl->GetTextSearchListener())
925 pImpl->DisableAsyncSearch();
928 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
929 if (pLoadingListener)
931 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
932 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
934 switch (ewkNavigationType)
936 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
937 navigationType = WEB_NAVIGATION_LINK_CLICKED;
939 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
940 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
942 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
943 navigationType = WEB_NAVIGATION_BACKFORWARD;
945 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
946 navigationType = WEB_NAVIGATION_RELOAD;
948 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
949 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
951 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
952 navigationType = WEB_NAVIGATION_OTHER;
958 if (pLoadingListener->OnLoadingRequested(url, navigationType))
960 ewk_policy_decision_ignore(pPolicy);
967 if (url == L"about:blank")
969 ewk_policy_decision_use(pPolicy);
974 String currentUrl(pImpl->GetUrl());
975 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
976 if (redirectUrl != L"")
978 ewk_policy_decision_ignore(pPolicy);
980 pImpl->LoadUrl(redirectUrl);
988 String uriScheme(uri.GetScheme());
989 SysSecureLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
991 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
993 ewk_policy_decision_ignore(pPolicy);
995 if (uriScheme == L"")
1000 result r = E_SUCCESS;
1002 if (uriScheme == L"tel")
1004 String operationId(L"http://tizen.org/appcontrol/operation/dial");
1005 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
1007 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
1009 String operationId(L"http://tizen.org/appcontrol/operation/compose");
1010 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
1014 String operationId(L"http://tizen.org/appcontrol/operation/view");
1015 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
1017 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1022 ewk_policy_decision_use(pPolicy);
1027 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1029 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1030 SysAssertf(pImpl, "Failed to request");
1032 if (pImpl->GetLoadingListener())
1034 result r = E_SUCCESS;
1036 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
1037 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1039 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1040 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1041 pEventArg.release();
1047 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1049 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1050 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1051 SysAssertf(pImpl, "Failed to request");
1053 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1055 if (pImpl->GetLoadingListener())
1057 result r = E_SUCCESS;
1059 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1060 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1061 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1063 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1064 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1065 pPageTitle.release();
1067 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1068 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1069 pEventArg.release();
1075 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1077 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1078 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1079 SysAssertf(pImpl, "Failed to request");
1081 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1083 if (pImpl->GetLoadingListener())
1085 result r = E_SUCCESS;
1087 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1088 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1089 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1091 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1092 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1093 pProgressPercentage.release();
1095 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1096 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1097 pEventArg.release();
1103 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1105 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1106 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1107 SysAssertf(pImpl && pPolicy, "Failed to request");
1109 result r = E_SUCCESS;
1111 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1112 String url(ewk_policy_decision_url_get(pPolicy));
1113 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1114 SysSecureLog(NID_WEB_CTRL, "code : %d, url : %ls, mime : %ls", code, url.GetPointer(), mime.GetPointer());
1116 if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1118 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1120 pImpl->SetRedirectRequested(true);
1124 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1125 if (pLoadingListener)
1127 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1128 HttpHeader httpHeader;
1130 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1131 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1133 pImpl->SetPolicyDecision(pLoadingListener->OnWebDataReceived(mime, httpHeader));
1137 pImpl->SetPolicyDecision(WEB_DECISION_CONTINUE);
1141 switch (pImpl->GetPolicyDecision())
1143 case WEB_DECISION_CONTINUE:
1145 String currentUrl(pImpl->GetUrl());
1146 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1147 if (redirectUrl != L"")
1149 pImpl->LoadUrl(redirectUrl);
1150 ewk_policy_decision_ignore(pPolicy);
1155 if (ewk_policy_decision_type_get(pPolicy) == EWK_POLICY_DECISION_USE)
1161 ewk_policy_decision_ignore(pPolicy);
1163 String operationId(L"http://tizen.org/appcontrol/operation/view");
1165 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1166 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1173 case WEB_DECISION_DOWNLOAD:
1175 ewk_policy_decision_ignore(pPolicy);
1177 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1178 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1180 Ewk_Context* pContext = ewk_view_context_get(pView);
1181 SysAssertf(pContext, "Failed to get webkit instance.");
1183 pDownloadHandler->StartDownload(url);
1188 case WEB_DECISION_IGNORE:
1190 ewk_policy_decision_ignore(pPolicy);
1201 ewk_policy_decision_use(pPolicy);
1206 ewk_policy_decision_ignore(pPolicy);
1211 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1213 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1214 SysAssertf(pImpl, "Failed to request");
1216 if (pImpl->IsRedirectRequested())
1218 pImpl->SetRedirectRequested(false);
1221 if (pImpl->IsLoadingErrorOccurred())
1223 pImpl->SetLoadingErrorOccurred(false);
1224 evas_object_smart_callback_call(pView, "load,finished", NULL);
1230 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1232 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1233 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1234 SysAssertf(pImpl && pErrorData, "Failed to request");
1236 int code = ewk_error_code_get(pErrorData);
1237 const char* pDescription = ewk_error_description_get(pErrorData);
1239 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1243 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1244 pImpl->SetLoadingErrorOccurred(true);
1247 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1248 evas_object_smart_callback_call(pView, "load,finished", NULL);
1251 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1252 pImpl->SetLoadingErrorOccurred(true);
1253 evas_object_smart_callback_call(pView, "load,stop", NULL);
1257 pImpl->SetLoadingErrorOccurred(true);
1258 if (pImpl->GetLoadingListener())
1260 result r = E_SUCCESS;
1262 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1263 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1271 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1273 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1274 SysAssertf(pImpl, "Failed to request");
1276 if (pImpl->GetLoadingListener())
1278 result r = E_SUCCESS;
1280 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1281 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1283 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1284 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1285 pEventArg.release();
1292 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1294 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1295 SysAssertf(pImpl, "Failed to request");
1297 if (pImpl->GetLoadingListener())
1299 result r = E_SUCCESS;
1301 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1302 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1304 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1305 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1306 pEventArg.release();
1313 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1315 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1316 SysAssertf(pImpl, "Failed to request");
1318 if (pImpl->GetLoadingListener())
1320 result r = E_SUCCESS;
1322 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1323 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1325 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1326 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1327 pEventArg.release();
1334 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1336 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1337 SysAssertf(pUrl && pImpl != null, "Failed to request");
1339 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1344 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1346 result r = E_SUCCESS;
1348 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1349 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1351 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1352 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1353 pEventArg.release();
1360 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1362 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1363 SysAssertf(pImpl, "Failed to request");
1365 if (pImpl->GetUiEventListener())
1367 result r = E_SUCCESS;
1369 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1370 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1372 if (pImpl->GetUiEventListenerF())
1374 result r = E_SUCCESS;
1376 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1377 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1383 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1385 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1386 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1387 SysAssertf(pParentImpl && pChildView, "Failed to request");
1389 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1390 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1391 if (pUserUiListener)
1393 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1396 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1397 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1399 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1400 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1403 if (pUserUiListenerF)
1405 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1408 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1409 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1411 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1412 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1419 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1421 result r = E_SUCCESS;
1423 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1424 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1426 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1427 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1428 pEventArg.release();
1435 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1437 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1438 SysAssertf(pChildImpl, "Failed to request");
1440 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1441 if (pParentImpl == null)
1446 if (pParentImpl->GetUiEventListener())
1448 result r = E_SUCCESS;
1450 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1451 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1453 if (pParentImpl->GetUiEventListenerF())
1455 result r = E_SUCCESS;
1457 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1458 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1464 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1466 result r = E_SUCCESS;
1468 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1469 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1470 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1472 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1473 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1474 pPreventTrigger.release();
1476 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1477 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1478 pEventArg.release();
1485 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1487 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1488 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1489 SysAssertf(pImpl && pTrigger, "Failed to request");
1491 if (pImpl->GetUiEventListener())
1493 result r = E_SUCCESS;
1495 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1496 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1498 if (pImpl->GetUiEventListenerF())
1500 result r = E_SUCCESS;
1502 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1503 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1509 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1511 result r = E_SUCCESS;
1513 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1514 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1515 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1517 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1519 if ((endPoint->x != 0) && (endPoint->y != 0))
1521 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1522 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1524 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1525 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1526 startPoint.release();
1528 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1529 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1532 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1533 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1534 pEventArg.release();
1542 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1544 result r = E_SUCCESS;
1546 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1547 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1549 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1551 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1553 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1555 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1556 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1558 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1559 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1560 startPoint.release();
1562 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1563 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1566 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1567 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1568 pEventArg.release();
1576 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1578 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1579 SysAssertf(pImpl, "Failed to request");
1581 if (pImpl->GetUiEventListener())
1583 result r = E_SUCCESS;
1585 r = FireWebPageBlockSelectedEvent(pImpl);
1586 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1588 if (pImpl->GetUiEventListenerF())
1590 result r = E_SUCCESS;
1592 r = FireWebPageBlockSelectedEventF(pImpl);
1593 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1599 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1601 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1602 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1603 SysAssertf(pImpl && pJsonText, "Failed to request");
1605 result r = E_SUCCESS;
1607 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1609 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1610 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1612 r = pEventArg->Construct(pJsonText);
1613 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1615 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1616 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1617 pEventArg.release();
1622 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1624 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1625 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1626 SysAssertf(pImpl && pEinaRect, "Failed to request");
1628 if (pImpl->IsVisible() == false)
1630 evas_object_focus_set(pView, EINA_FALSE);
1633 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1635 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1636 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1638 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1640 if (rect.height == 0)
1645 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1648 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1650 if (pFormImpl->HasFooter())
1652 pFormImpl->GetCore().SetKeypadShowState(true);
1657 if (pImpl->GetWebKeypadEventListener())
1659 if (pImpl->IsKeypadVisible() == true)
1661 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1663 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1668 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1671 pImpl->SetKeypadVisibleState(true);
1672 pImpl->SetPreviousKeypadBounds(rect);
1676 result r = pImpl->SetFullScreenKeypad();
1677 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1683 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1685 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1686 SysAssertf(pImpl, "Failed to request");
1688 if (pImpl->GetWebKeypadEventListener())
1690 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1696 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1698 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1699 SysAssertf(pImpl, "Failed to request");
1701 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1704 pFormImpl->DeflateClientRectHeight(0);
1706 if (pFormImpl->HasFooter())
1708 pFormImpl->GetCore().SetKeypadShowState(false);
1713 if (pImpl->GetWebKeypadEventListener())
1715 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1718 pImpl->SetKeypadVisibleState(false);
1723 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1725 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1726 SysAssertf(pImpl, "Failed to request");
1728 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true && pImpl->IsFocused() == true)
1730 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1731 SysAssertf(pWebCore, "Failed to get Web core object");
1733 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1735 pImpl->SetKeypadVisibleState(true);
1741 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1743 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1744 SysAssertf(pImpl, "Failed to request");
1746 if (pImpl->IsKeypadOpened() == true)
1748 pImpl->SetKeypadOpened(false);
1754 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1756 SysAssertf(pSmartData, "invalid smartdata");
1757 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1758 SysAssertf(pWebImpl, "Failed to get Impl");
1760 result r = E_SUCCESS;
1762 if (pWebImpl->GetColorpicker())
1769 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1770 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1772 byte r1, g1, b1, a1;
1773 color.GetColorComponents(r1, g1, b1, a1);
1774 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1781 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1783 SysAssertf(pSmartData, "invalid smartdata");
1785 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1786 SysAssertf(pWebImpl, "Failed to get Impl");
1788 return pWebImpl->HideColorPicker();
1793 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1795 SysAssertf(pSmartData, "Failed to request");
1796 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1797 SysAssertf(pWebImpl, "Failed to get Impl");
1799 result r = E_SUCCESS;
1801 if (pWebImpl->GetDatepicker())
1803 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1810 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1811 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1813 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1814 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1816 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1823 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1825 SysAssertf(pSmartData, "Failed to request");
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->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1831 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1838 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1840 SysAssertf(pSmartData, "Failed to request");
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->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1846 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1853 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1855 SysAssertf(pSmartData, "invalid smartdata");
1857 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1858 SysAssertf(pWebImpl, "Failed to get Impl");
1860 result r = pWebImpl->ClearSelectBoxPopup();
1861 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1868 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1870 SysAssertf(pSmartData, "invalid smartdata");
1872 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1873 SysAssertf(pWebImpl, "Failed to get Impl");
1875 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1876 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1883 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1885 SysAssertf(pSmartData, "Failed to request");
1887 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1888 SysAssertf(pWebImpl, "Failed to get Impl");
1890 Rectangle windowRect(x, y, w, h);
1891 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1892 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1899 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
1901 SysAssertf(pSmartData, "Failed to request");
1903 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1904 SysAssertf(pWebImpl, "Failed to get Impl");
1906 if (pWebImpl->IsFormDataWindowVisible())
1908 pWebImpl->HideFormDataWindow();
1916 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
1918 SysAssertf(pSmartData, "Failed to request");
1920 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1921 SysAssertf(pWebImpl, "Failed to get Impl");
1923 pWebImpl->SetFormDataList(pDataList);
1930 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
1932 SysAssertf(pSmartData, "Failed to request");
1934 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1935 SysAssertf(pWebImpl, "Failed to get Impl");
1937 if (pWebImpl->IsFormDataWindowVisible())
1949 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1951 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1952 SysAssertf(pPresenter && !pError, "Failed to request");
1954 bool ret = EINA_TRUE;
1958 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1960 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1964 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1973 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1975 pPresenter->EndAsyncProcess(ret);
1980 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1982 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1983 SysAssertf(pPresenter, "Failed to request");
1985 String result(pResult);
1986 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1988 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
1989 _WebManager* pWebManager = _WebManager::GetInstance();
1990 if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
1992 pPresenter->EndAsyncProcess(result);
1998 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2000 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2001 SysAssertf(pImpl, "Failed to request");
2003 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2004 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2006 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2010 pWebPresenter->EndAsyncProcess(*pTotalCount);
2014 if (pImpl->GetTextSearchListener())
2016 result r = E_SUCCESS;
2020 if (*pTotalCount > 0)
2022 ordinal = pImpl->GetAsyncSearchOrdinal();
2023 pImpl->SetAsyncSearchResult(*pTotalCount);
2026 if (pImpl->GetPendingAsyncSearchCount() > 0)
2031 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2032 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2033 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2034 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2036 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2037 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2040 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2041 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2044 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2045 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2046 pEventArg.release();
2052 class _JsBridgeHashCodeProvider
2053 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2056 _JsBridgeHashCodeProvider(){}
2057 virtual ~_JsBridgeHashCodeProvider(void) {}
2060 int GetHashCode(const Tizen::Base::String& obj) const
2062 return obj.GetHashCode();
2068 //Comparer implementation
2069 class _JsBridgeComparer
2070 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2073 _JsBridgeComparer(){}
2074 virtual ~_JsBridgeComparer(void) {}
2077 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2094 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2095 : _ContainerImpl(pWeb, pCore)
2096 , __isFooterVisible(false)
2097 , __isKeypadVisible(false)
2098 , __isKeypadOpened(false)
2099 , __isLoadingErrorOccurred(false)
2100 , __isRedirectRequested(false)
2101 , __isCertificateRequested(false)
2102 , __isCertificateConfirmed(false)
2103 , __isFormDataVisible(false)
2104 , __keypadBounds(0, 0, 0, 0)
2106 , __pUserLoadingListener(null)
2107 , __pUserUiListener(null)
2108 , __pUserUiListenerF(null)
2109 , __pUserKeypadEventListener(null)
2110 , __pTextSearchListener(null)
2112 , __pJsBridgeList(null)
2113 , __pJsProvider(null)
2114 , __pJsComparer(null)
2115 , __pWebDownloadHandler(null)
2117 , __pAuthChallenge(null)
2118 , __pAuthPopup(null)
2119 , __pUserMediaConfirmPopup(null)
2120 , __pContentHandlerConfirmPopup(null)
2121 , __pProtocolHandlerConfirmPopup(null)
2122 , __pGeolocationConfirmPopup(null)
2123 , __pNotificationConfirmPopup(null)
2124 , __pScriptAlertConfirmPopup(null)
2125 , __pScriptConfirmPopup(null)
2126 , __pAppCacheConfirmPopup(null)
2127 , __pDbQuotaConfirmPopup(null)
2128 , __pLocalFsQuotaConfirmPopup(null)
2129 , __pIndexedDbQuotaConfirmPopup(null)
2130 , __pPromptPopup(null)
2131 , __pCertConfirmPopup(null)
2132 , __pSelectBox(null)
2133 , __pDatePicker(null)
2134 , __pColorPicker(null)
2135 , __pFormDataWindow(null)
2137 , __policy(WEB_DECISION_CONTINUE)
2138 , __defaultUserAgent(L"")
2139 , __pFormDataList(null)
2140 , __popupClosed(false)
2142 __textSearch.__searchAll = false;
2143 __textSearch.__searchForward = true;
2144 __textSearch.__caseSensitive = false;
2145 __textSearch.__pending = 0;
2146 __textSearch.__currentIndex = 1;
2147 __textSearch.__totalCount = -1;
2148 __textSearch.__text = L"";
2152 _WebImpl::~_WebImpl()
2154 _WebManager* pWebManager = _WebManager::GetInstance();
2155 SysTryCatch(NID_WEB_CTRL, pWebManager, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2157 pWebManager->RemoveWeb(reinterpret_cast< int >(this));
2158 pWebManager->RemoveActiveWeb(this);
2161 RemoveEventListenerCallback();
2163 ClearCertificateDb();
2168 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2170 result r = E_SUCCESS;
2172 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2173 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2175 _Web* pCore = _Web::CreateWebN();
2176 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2178 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2180 r = CheckConstruction(pCore, pImpl);
2181 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2183 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2184 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2186 r = pImpl->Construct();
2187 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2199 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2201 result r = E_SUCCESS;
2203 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2204 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2206 _Web* pCore = _Web::CreateWebN();
2207 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2209 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2211 r = CheckConstruction(pCore, pImpl);
2212 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2214 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2215 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2217 r = pImpl->Construct();
2218 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2230 _WebImpl::Construct(void)
2232 result r = E_SUCCESS;
2234 r = __mutex.Create();
2235 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2237 r = __textSearch.__searchQueue.Construct();
2238 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2240 r = __webNotificationList.Construct();
2241 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2243 r = InitJsBridgeList();
2244 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2247 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2249 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2250 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2257 _WebImpl::InitializeSetting(void)
2259 result r = E_SUCCESS;
2261 WebSetting* pWebSetting = __pWebCore->GetSetting();
2262 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2264 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2265 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2267 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2269 r = SetSetting(*pWebSetting);
2270 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2272 SetEventListenerCallback();
2279 _WebImpl::IsLayoutable(void) const
2286 _WebImpl::InitWebEvent(void)
2288 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2289 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2291 return __pWebEvent->Construct(*this);
2296 _WebImpl::GetWebEvent(void) const
2298 return __pWebEvent.get();
2303 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2305 Eina_Hash* pHttpHeader = null;
2307 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2308 if (pFieldNameList.get())
2310 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2311 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2313 int count = pFieldNameList->GetCount();
2315 for (int i = 0; i < count; i++)
2317 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2318 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2320 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2321 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2323 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2324 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2326 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2328 Eina_Bool ret = false;
2330 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2331 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2333 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2334 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2336 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2337 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2344 eina_hash_free(pHttpHeader);
2351 _WebImpl::LoadUrl(const String& url) const
2353 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2354 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2356 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2363 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2365 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2366 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2368 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2370 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2372 eina_hash_free(pHttpHeader);
2379 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2381 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2382 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2384 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2386 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2388 eina_hash_free(pHttpHeader);
2395 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2397 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2399 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2400 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2401 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2402 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2404 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2411 _WebImpl::Pause(void)
2413 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2418 _WebImpl::Resume(void)
2420 ewk_view_resume(__pWebCore->GetWebNativeNode());
2425 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2427 __pSelectBox.reset();
2429 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2431 result r = E_SUCCESS;
2433 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2434 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2436 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2437 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2439 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2440 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2442 __pSelectBox = std::move(pSelectBox);
2444 return __pSelectBox->ShowPopup();
2449 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2451 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2453 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2458 _WebImpl::ClearSelectBoxPopup(void)
2460 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2462 __pSelectBox.reset();
2471 _WebImpl::GetDatepicker(void)
2473 _InputPickerPopup* pInputPicker =null;
2476 pInputPicker = __pDatePicker.get();
2478 return pInputPicker;
2483 _WebImpl::GetColorpicker(void)
2485 _InputPickerPopup* pInputPicker =null;
2488 pInputPicker = __pColorPicker.get();
2490 return pInputPicker;
2495 _WebImpl::CanGoBack(void) const
2497 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2502 _WebImpl::CanGoForward(void) const
2504 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2509 _WebImpl::GoBack(void) const
2511 ewk_view_back(__pWebCore->GetWebNativeNode());
2516 _WebImpl::GoForward(void) const
2518 ewk_view_forward(__pWebCore->GetWebNativeNode());
2523 _WebImpl::GetUrl(void) const
2525 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2530 _WebImpl::GetTitle(void) const
2532 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2537 _WebImpl::StopLoading(void) const
2539 ewk_view_stop(__pWebCore->GetWebNativeNode());
2544 _WebImpl::Reload(void) const
2546 ewk_view_reload(__pWebCore->GetWebNativeNode());
2551 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2553 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2559 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2560 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2562 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2563 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2565 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2567 String* pResult = new (std::nothrow) String(L"");
2568 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2570 pPresenter->WaitAsyncProcess(*pResult);
2577 _WebImpl::SetZoomLevel(float level)
2579 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);
2581 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2588 _WebImpl::GetZoomLevel(void) const
2590 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2594 const PageNavigationList*
2595 _WebImpl::GetBackForwardListN(void) const
2597 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2603 result r = E_SUCCESS;
2605 _PageNavigationListImpl* pNavigationListImpl = null;
2606 _HistoryItemImpl* pHistoryItemImpl = null;
2608 std::unique_ptr<PageNavigationList> pNavigationList;
2609 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2612 int forwardCount = 0;
2617 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2618 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2620 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2621 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2623 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2624 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2626 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2627 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2629 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2630 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2632 r = pHistoryList->Construct();
2633 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2635 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2636 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2637 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2639 for (int i = -backCount; i < forwardCount + 1; i++)
2641 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2642 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2644 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2645 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2647 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2648 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2650 url = ewk_history_item_uri_get(pEwkItem);
2651 title = ewk_history_item_title_get(pEwkItem);
2652 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2654 pHistoryItemImpl->SetHistoryItem(url, title);
2656 r = pHistoryList->Add(*pHistoryItem.get());
2657 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2658 pHistoryItem.release();
2661 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2663 ewk_history_free(pEwkHistoryList);
2665 return pNavigationList.release();
2668 ewk_history_free(pEwkHistoryList);
2675 _WebImpl::SearchText(const String& text, bool searchForward)
2677 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2683 result r = E_SUCCESS;
2685 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2689 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2692 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2693 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2695 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
2696 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
2699 pPresenter->WaitAsyncProcess(result);
2701 return static_cast < bool >(result);
2706 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2708 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2714 result r = E_SUCCESS;
2716 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2720 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2723 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2724 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2731 _WebImpl::SearchNextAsync(bool searchForward)
2733 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2739 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2740 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2741 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2743 result r = E_SUCCESS;
2745 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2747 if (!__textSearch.__caseSensitive)
2749 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2754 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2757 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2758 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2765 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2767 MutexGuard lock(__mutex);
2769 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2770 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2772 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2773 SysAssertf(pSettings, "Failed to get webkit instance.");
2774 ewk_settings_clear_text_selection_automatically_set(pSettings, true);
2779 if (__textSearch.__searchAll)
2781 DisableAsyncSearch();
2783 __textSearch.__searchQueue.Enqueue(this);
2784 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2786 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2787 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2791 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2793 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2797 case SEARCH_ALL_ASYNC:
2798 __textSearch.__searchAll = true;
2799 __textSearch.__text = text;
2800 __textSearch.__searchForward = true;
2801 __textSearch.__caseSensitive = caseSensitive;
2802 __textSearch.__totalCount = -1;
2803 __textSearch.__currentIndex = 1;
2805 __textSearch.__searchQueue.Enqueue(this);
2806 __textSearch.__searchQueue.Enqueue(this);
2808 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2809 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2812 case SEARCH_NEXT_ASYNC:
2813 __textSearch.__searchForward = searchForward;
2815 CalculateAsyncSearchOrdinal();
2817 __textSearch.__searchQueue.Enqueue(this);
2819 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2831 _WebImpl::SetAsyncSearchResult(int totalCount)
2833 __textSearch.__totalCount = totalCount;
2838 _WebImpl::GetSearchPresenter(void)
2840 MutexGuard lock(__mutex);
2842 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2847 _WebImpl::GetPendingAsyncSearchCount(void) const
2849 return __textSearch.__searchQueue.GetCount();
2854 _WebImpl::CalculateAsyncSearchOrdinal(void)
2856 if (__textSearch.__searchForward)
2858 __textSearch.__currentIndex++;
2862 __textSearch.__currentIndex--;
2868 _WebImpl::GetAsyncSearchOrdinal(void) const
2870 return __textSearch.__currentIndex;
2875 _WebImpl::DisableAsyncSearch(void)
2877 __textSearch.__searchAll = false;
2882 _WebImpl::SetSetting(const WebSetting& setting)
2884 if (__pWebCore->GetWebNativeNode())
2886 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2887 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2888 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2890 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2891 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2893 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2895 switch (setting.GetCacheControl())
2897 case WEB_CACHE_VALIDATED:
2898 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2901 case WEB_CACHE_IGNORE:
2902 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2909 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2911 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2915 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2918 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2920 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2922 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2924 if (__defaultUserAgent != setting.GetUserAgent())
2926 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2927 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2929 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2932 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2934 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2936 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2938 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2941 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2943 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2944 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2945 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2946 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2947 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2948 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2949 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2950 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2951 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2952 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2953 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2954 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2955 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2962 _WebImpl::GetSetting(void) const
2964 return *__pWebCore->GetSetting();
2968 const HitElementResult*
2969 _WebImpl::GetElementByPointN(const Point& point) const
2971 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
2975 const HitElementResult*
2976 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2978 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2984 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));
2986 result r = E_SUCCESS;
2988 _HitElementResultImpl* pHitElementResultImpl = null;
2990 std::unique_ptr<HitElementResult> pHitElementResult;
2991 std::unique_ptr<Bitmap> pImage;
2992 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2994 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
2996 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2997 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2999 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3000 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3001 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3002 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3003 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3005 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3007 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3008 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3010 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3011 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3013 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3019 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3020 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3021 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3022 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3024 r = buf.Construct(imageLength);
3025 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3027 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3028 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3032 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3033 // webkit support types such as ico and vp8 additionally
3034 if (strcmp(pExtension, "gif") == 0)
3036 format = IMG_FORMAT_GIF;
3038 else if (strcmp(pExtension, "jpg") == 0)
3040 format = IMG_FORMAT_JPG;
3042 else if (strcmp(pExtension, "png") == 0)
3044 format = IMG_FORMAT_PNG;
3046 else if (strcmp(pExtension, "bmp") == 0)
3048 format = IMG_FORMAT_BMP;
3052 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3056 r = image.Construct();
3057 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3059 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3060 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3065 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3066 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3068 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3069 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3071 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3072 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3075 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3077 ewk_hit_test_free(pEwkHitTest);
3079 return pHitElementResult.release();
3082 ewk_hit_test_free(pEwkHitTest);
3089 _WebImpl::IsLoading(void) const
3091 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3093 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3105 _WebImpl::GetTextFromBlock(void) const
3107 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3112 _WebImpl::IsPrivateBrowsingEnabled(void) const
3114 if (__pWebCore->GetWebNativeNode() == null)
3116 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3119 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3120 SysAssertf(pSettings, "Failed to get webkit instance.");
3122 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3127 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3129 if (__pWebCore->GetWebNativeNode() == null)
3131 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3135 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3136 SysAssertf(pSettings, "Failed to get webkit instance.");
3138 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3143 _WebImpl::ClearHistory(void)
3145 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3150 _WebImpl::ClearCache(void)
3152 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3154 ewk_context_cache_clear(pContext);
3159 _WebImpl::ClearCookie(void)
3161 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3162 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3164 ewk_cookie_manager_cookies_clear(pCookieManager);
3169 _WebImpl::ClearFormData(void)
3171 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3173 ewk_context_form_candidate_data_clear(pContext);
3178 _WebImpl::ClearLoginFormData(void)
3180 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3182 ewk_context_form_password_data_clear(pContext);
3187 _WebImpl::IsCookieEnabled(void) const
3189 if (__pWebCore->GetWebNativeNode() == null)
3191 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3194 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3195 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3196 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3198 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
3199 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3201 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
3203 bool result = false;
3204 pPresenter->WaitAsyncProcess(result);
3211 _WebImpl::SetCookieEnabled(bool enable)
3213 if (__pWebCore->GetWebNativeNode() == null)
3215 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3220 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3221 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3222 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3226 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3230 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3231 ewk_cookie_manager_cookies_clear(pCookieManager);
3237 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3239 result r = E_SUCCESS;
3241 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3242 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3245 String fileExtension = File::GetFileExtension(filePath);
3246 int pathLength = filePath.GetLength();
3249 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3251 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3252 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3253 r = filePath.SubString(0, index + 1, dirPath);
3254 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3256 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3257 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3261 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3263 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3267 Evas_Coord contentsWidth;
3268 Evas_Coord contentsHeight;
3270 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3271 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3279 _WebImpl::IsMimeSupported(const String& mime) const
3281 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3282 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3284 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3289 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3291 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3296 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3298 __pUserUiListener = pUiEventListener;
3303 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3305 __pUserUiListenerF = pUiEventListener;
3310 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3312 __pUserKeypadEventListener = pKeypadEventListener;
3317 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3319 if (__pWebDownloadHandler.get() == null)
3321 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3322 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3325 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3326 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3331 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3333 __pTextSearchListener = pTextSearchListener;
3338 _WebImpl::SetScrollEnabled(bool enable)
3340 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3345 _WebImpl::IsScrollEnabled(void) const
3347 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3352 _WebImpl::InitJsBridgeList(void)
3354 result r = E_SUCCESS;
3356 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3357 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3359 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3360 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3362 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3363 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3365 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3366 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3368 __pJsBridgeList = std::move(pJsBridgeList);
3375 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3377 result r = E_SUCCESS;
3379 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3380 String key(pJsBridge->GetName());
3382 r = __pJsBridgeList->Add(key, pJsBridge);
3383 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3390 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3392 result r = E_SUCCESS;
3394 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3395 String key(pJsBridge->GetName());
3397 r = __pJsBridgeList->Remove(key);
3398 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3405 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3407 result r = E_SUCCESS;
3409 IJsonValue* pJsonValue = null;
3410 IJavaScriptBridge* pJsBridge = null;
3412 String key(L"name");
3414 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3415 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));
3417 r = pJsonObject->GetValue(&key, pJsonValue);
3418 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3420 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3421 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3423 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3424 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3431 _WebImpl::GetLoadingListener(void) const
3433 return __pUserLoadingListener;
3437 IWebUiEventListener*
3438 _WebImpl::GetUiEventListener(void) const
3440 return __pUserUiListener;
3444 IWebUiEventListenerF*
3445 _WebImpl::GetUiEventListenerF(void) const
3447 return __pUserUiListenerF;
3451 IWebKeypadEventListener*
3452 _WebImpl::GetWebKeypadEventListener(void) const
3454 return __pUserKeypadEventListener;
3458 ITextSearchListener*
3459 _WebImpl::GetTextSearchListener(void) const
3461 return __pTextSearchListener;
3466 _WebImpl::SetEventListenerCallback(void) const
3468 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3471 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3472 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3474 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3475 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3477 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3478 SysAssertf(pSmartData, "Failed to request");
3480 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3481 SysAssertf(pSmart, "Failed to request");
3483 pSmart->popup_menu_show = OnSelectBoxRequested;
3484 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3485 pSmart->popup_menu_hide = OnSelectBoxClosed;
3486 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3488 pSmart->input_picker_show = OnDatePickerProviderRequested;
3489 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3490 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3492 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3493 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3494 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3495 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3497 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3499 // add loading event callbacks for ILoadingListener
3500 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3501 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3503 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3504 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3505 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3506 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3507 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3508 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3509 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3510 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3512 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3514 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3516 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3517 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3518 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3520 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3521 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3523 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3525 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3526 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3527 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3529 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3531 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3532 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3533 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3535 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3536 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3537 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3539 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3540 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3541 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3543 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3544 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3545 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3546 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3548 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3549 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3551 evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
3553 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
3554 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
3556 evas_object_smart_callback_add(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested, this);
3557 evas_object_smart_callback_add(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested, this);
3559 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3560 SysAssertf(pContext, "Failed to get webkit instance.");
3561 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3562 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3564 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3565 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3566 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3567 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3569 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3575 _WebImpl::RemoveEventListenerCallback(void) const
3577 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3580 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3581 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3583 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3584 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3586 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3587 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3589 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3590 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3591 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3592 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3593 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3594 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3595 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3596 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3598 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3600 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3602 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3603 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3604 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3606 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3607 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3609 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3611 ewk_view_javascript_alert_callback_set(pWebNativeNode, null, null);
3612 ewk_view_javascript_prompt_callback_set(pWebNativeNode, null, null);
3613 ewk_view_javascript_confirm_callback_set(pWebNativeNode, null, null);
3615 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3617 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3618 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3619 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3621 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3622 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3623 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3624 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3625 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3626 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3628 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3629 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3630 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3632 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3634 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3635 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3637 evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
3639 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
3640 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
3642 evas_object_smart_callback_del(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested);
3643 evas_object_smart_callback_del(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested);
3645 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3646 SysAssertf(pContext, "Failed to get webkit instance.");
3647 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3649 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3650 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3651 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3652 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3654 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3660 _WebImpl::ClearCertificateDb(void)
3662 result r = E_SUCCESS;
3664 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3665 String table(CERTIFICATE_TABLE_NAME);
3668 r = db.Construct(certificatePath, "r+", null);
3669 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3671 db.BeginTransaction();
3673 r = db.ExecuteSql(L"Delete From " + table, true);
3674 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3676 db.CommitTransaction();
3681 db.RollbackTransaction();
3686 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3688 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3693 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3695 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3696 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
3697 if (pSmartData && pSmartData->api)
3699 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3701 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3702 SysAssertf(pSettings, "Failed to get webkit instance.");
3703 ewk_settings_clear_text_selection_automatically_set(pSettings, true);
3705 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3708 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3710 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3711 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3713 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3715 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3717 ewk_view_command_execute(pView, "SelectWord", 0);
3721 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3722 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3725 ewk_view_command_execute(pView, "SelectWord", 0);
3731 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3733 evas_object_smart_callback_call(pView, "text,selected", NULL);
3740 _WebImpl::ReleaseBlock(void)
3742 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3747 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3749 FloatPoint tempStartPoint;
3750 FloatPoint tempEndPoint;
3752 GetBlockRange(tempStartPoint, tempEndPoint);
3754 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3755 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3760 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3762 Eina_Rectangle leftHandle;
3763 Eina_Rectangle rightHandle;
3765 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3766 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3768 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3770 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3771 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3772 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3773 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3775 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3777 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3778 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3784 _WebImpl::GetFaviconN(void) const
3786 result r = E_SUCCESS;
3788 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3789 Ewk_Context* pContext = ewk_view_context_get(pView);
3790 const char* pUrl = ewk_view_url_get(pView);
3791 Evas* pEvas = evas_object_evas_get(pView);
3793 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3799 Tizen::Graphics::BufferInfo bufferInfo;
3801 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3802 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3804 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3805 Tizen::Base::ByteBuffer byteBuffer;
3807 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3808 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3810 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3811 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3813 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3814 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3816 return pImage.release();
3822 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3824 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3829 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3831 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3836 _WebImpl::GetScrollPosition(void) const
3840 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3847 _WebImpl::GetPageSize(void) const
3849 Evas_Coord width = 0;
3850 Evas_Coord height = 0;
3852 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3854 Dimension size(static_cast< int >(width), static_cast< int >(height));
3861 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
3863 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3865 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3866 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3868 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
3870 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
3877 _WebImpl::RemoveHttpHeaderField(const String& name)
3879 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3881 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3882 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3884 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
3891 _WebImpl::SetLoadingErrorOccurred(bool arg)
3893 __isLoadingErrorOccurred = arg;
3898 _WebImpl::IsLoadingErrorOccurred(void) const
3900 return __isLoadingErrorOccurred;
3905 _WebImpl::SetRedirectRequested(bool arg)
3907 __isRedirectRequested = arg;
3912 _WebImpl::IsRedirectRequested(void) const
3914 return __isRedirectRequested;
3919 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3926 _WebImpl::GetPolicyDecision(void) const
3933 _WebImpl::SetCertificateRequested(bool arg)
3935 __isCertificateRequested = arg;
3940 _WebImpl::IsCertificateRequested(void) const
3942 return __isCertificateRequested;
3947 _WebImpl::SetCertificateConfirmed(bool arg)
3949 __isCertificateConfirmed = arg;
3954 _WebImpl::IsCertificateConfirmed(void) const
3956 return __isCertificateConfirmed;
3961 _WebImpl::SetFullScreenKeypad(void)
3963 result r = E_SUCCESS;
3965 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3966 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3968 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3969 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3971 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3972 pKeypad->SetText(text);
3974 r = pKeypad->SetShowState(true);
3975 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3977 r = pKeypad->Show();
3978 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3980 pKeypad->AddTextEventListener(*this);
3982 __pKeypad = std::move(pKeypad);
3989 _WebImpl::RemoveFullScreenKeypad(void)
3991 __pKeypad->RemoveTextEventListener(*this);
3998 _WebImpl::IsFooterVisible(void) const
4000 return __isFooterVisible;
4005 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4007 __isFooterVisible = isFooterVisible;
4012 _WebImpl::IsKeypadVisible(void) const
4014 return __isKeypadVisible;
4019 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4021 __isKeypadVisible = isKeypadVisible;
4026 _WebImpl::IsKeypadOpened(void) const
4028 return __isKeypadOpened;
4032 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4034 __isKeypadOpened = isKeypadOpened;
4039 _WebImpl::GetPreviousKeypadBounds(void) const
4041 return __keypadBounds;
4046 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4048 __keypadBounds = bounds;
4053 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4055 RemoveFullScreenKeypad();
4060 _WebImpl::OnTextValueChanged(const Control& source)
4062 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4064 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4066 RemoveFullScreenKeypad();
4071 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4073 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4074 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4076 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4077 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4079 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4080 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4082 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4089 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4091 result r = E_SUCCESS;
4093 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4094 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4096 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4098 ILoadingListener* pLoadingListner = GetLoadingListener();
4099 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4101 switch (pEventArg->GetEventType())
4103 case WEB_EVENT_LOADINGLISTENER_STARTED:
4105 pLoadingListner->OnLoadingStarted();
4109 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4111 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4112 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4114 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4118 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4120 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4121 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4123 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4127 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4129 pLoadingListner->OnLoadingCanceled();
4133 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4135 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4136 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4138 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4139 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4141 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4143 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4147 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4149 pLoadingListner->OnLoadingCompleted();
4153 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4155 pLoadingListner->OnHttpAuthenticationCanceled();
4159 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4161 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4162 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4166 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4182 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4184 result r = E_SUCCESS;
4186 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4187 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4189 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4191 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4192 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4194 switch (pEventArg->GetEventType())
4196 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4198 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4199 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4201 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4205 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4207 pWebDownloadListener->OnWebDataDownloadCompleted();
4211 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4213 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4214 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4216 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4218 pWebDownloadListener->OnWebDownloadFailed(errorType);
4233 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4235 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4236 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4238 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4240 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4242 switch (pEventArg->GetEventType())
4244 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4246 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4248 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4249 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4251 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4252 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4254 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4258 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4260 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4262 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4266 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4268 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4270 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4274 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4276 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4278 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4279 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4281 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4296 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4298 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4299 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4301 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4303 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4305 switch (pEventArg->GetEventType())
4307 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4309 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4311 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4312 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4314 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4315 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4317 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4321 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4323 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4325 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4329 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4331 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4333 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4337 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4339 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4341 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4342 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4344 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4359 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4361 result r = E_SUCCESS;
4363 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4364 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4366 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4368 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4369 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4371 switch (pEventArg->GetEventType())
4373 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4375 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4376 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4378 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4379 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4381 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4396 _WebImpl::VibrationRequested(uint64_t duration)
4398 result r = E_SUCCESS;
4400 __pVibrator.reset();
4402 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4403 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4405 r = pVibrator->Construct();
4406 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4408 __pVibrator = std::move(pVibrator);
4410 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4412 r = __pVibrator->Start(&pattern, 1, 1);
4413 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4420 _WebImpl::VibrationCanceled(void)
4422 __pVibrator.reset();
4427 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4429 result r = E_SUCCESS;
4431 String host(ewk_auth_challenge_url_get(pChallenge));
4432 String realm(ewk_auth_challenge_realm_get(pChallenge));
4434 __pAuthChallenge.reset();
4436 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4437 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4439 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4440 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4442 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4443 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4445 __pAuthChallenge = std::move(pAuthChallenge);
4447 ewk_auth_challenge_suspend(pChallenge);
4448 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4450 __pAuthChallenge.release();
4454 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4455 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4463 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4465 result r = E_SUCCESS;
4467 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4468 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4470 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4471 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4473 __pAuthPopup = std::move(pAuthPopup);
4475 int modalResult = 0;
4477 r = __pAuthPopup->ShowAndWait(modalResult);
4478 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4483 __pAuthPopup.reset();
4491 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4493 result r = E_SUCCESS;
4495 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4496 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4498 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4499 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4501 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4503 int modalResult = 0;
4505 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4506 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4508 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4510 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4514 if (__pCertConfirmPopup.get())
4516 __pCertConfirmPopup.reset();
4524 _WebImpl::ShowPromptPopup(String msg, String defVal)
4526 result r = E_SUCCESS;
4528 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4529 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4531 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
4532 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4534 __pPromptPopup = std::move(pPromptPopup);
4536 r = __pPromptPopup->ShowPopup();
4537 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4542 __pPromptPopup.reset();
4550 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4552 result r = E_SUCCESS;
4554 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4555 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4557 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg);
4558 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4560 int modalResult = 0;
4562 switch(userConfirmMode)
4564 case USER_CONTENT_HANDLER:
4566 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4568 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4569 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4571 __pContentHandlerConfirmPopup.reset();
4573 ewk_view_resume(__pWebCore->GetWebNativeNode());
4577 case USER_PROTOCOL_HANDLER:
4579 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4581 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4582 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4584 __pProtocolHandlerConfirmPopup.reset();
4586 ewk_view_resume(__pWebCore->GetWebNativeNode());
4590 case USER_CONFIRM_APP_CACHE:
4592 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4594 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4595 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4597 __pAppCacheConfirmPopup.reset();
4599 ewk_view_resume(__pWebCore->GetWebNativeNode());
4603 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4605 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4607 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4608 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4610 __pDbQuotaConfirmPopup.reset();
4612 ewk_view_resume(__pWebCore->GetWebNativeNode());
4616 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4618 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4620 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4621 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4623 __pLocalFsQuotaConfirmPopup.reset();
4625 ewk_view_resume(__pWebCore->GetWebNativeNode());
4629 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4631 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4633 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4634 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4636 __pIndexedDbQuotaConfirmPopup.reset();
4638 ewk_view_resume(__pWebCore->GetWebNativeNode());
4651 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4653 result r = E_SUCCESS;
4655 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4656 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4658 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg);
4659 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4661 switch(userConfirmMode)
4663 case USER_CONFIRM_USERMEDIA:
4665 __pUserMediaConfirmPopup.reset();
4667 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4669 r = __pUserMediaConfirmPopup->ShowPopup();
4670 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4674 case USER_CONFIRM_GEOLOCATION:
4676 __pGeolocationConfirmPopup.reset();
4678 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4680 r = __pGeolocationConfirmPopup->ShowPopup();
4681 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4685 case USER_CONFIRM_NOTIFICATION:
4687 __pNotificationConfirmPopup.reset();
4689 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4691 r = __pNotificationConfirmPopup->ShowPopup();
4692 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4696 case USER_SCRIPT_ALERT:
4698 __pScriptAlertConfirmPopup.reset();
4700 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4702 r = __pScriptAlertConfirmPopup->ShowPopup();
4703 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4707 case USER_SCRIPT_CONFIRM:
4709 __pScriptConfirmPopup.reset();
4711 __pScriptConfirmPopup = std::move(pUserConfirmPopup);
4713 r = __pScriptConfirmPopup->ShowPopup();
4714 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4730 _WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl)
4733 _FormImpl* pFormImpl = null;
4735 _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent());
4736 if (!pParentControlImpl)
4741 pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl);
4747 return GetParentFormImpl(pParentControlImpl);
4752 _WebImpl::OnFocusGained(const _ControlImpl& source)
4754 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4755 SysAssertf(pSettings, "Failed to get webkit instance.");
4756 ewk_settings_clear_text_selection_automatically_set(pSettings, true);
4763 _WebImpl::OnFocusLost(const _ControlImpl& source)
4765 if(IsKeypadVisible() == true)
4767 SetKeypadOpened(true);
4769 SetKeypadVisibleState(false);
4772 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4773 SysAssertf(pSettings, "Failed to get webkit instance.");
4774 ewk_settings_clear_text_selection_automatically_set(pSettings, false);
4776 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4783 _WebImpl::HasValidNativeNode(void) const
4785 if (__pWebCore && __pWebCore->GetWebNativeNode())
4795 _WebImpl::OnPreAttachedToMainTree(void)
4797 result r = E_SUCCESS;
4799 if (IsVisible() == true)
4801 _WebManager* pWebManager = _WebManager::GetInstance();
4802 pWebManager->SetActiveWeb(this);
4805 r = _ContainerImpl::OnPreAttachedToMainTree();
4806 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4808 if (!HasValidNativeNode())
4810 r = __pWebCore->InitializeWebNativeNode();
4811 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4813 _ControlManager* pControlManager = _ControlManager::GetInstance();
4814 SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance.");
4815 OnChangeLayout(pControlManager->GetScreenRotation());
4817 r = InitializeSetting();
4818 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4820 _WebManager* pWebManager = _WebManager::GetInstance();
4821 pWebManager->AddWeb(reinterpret_cast< int >(this));
4829 _WebImpl::OnDetachingFromMainTree(void)
4831 result r = E_SUCCESS;
4833 _WebManager* pWebManager = _WebManager::GetInstance();
4834 pWebManager->RemoveActiveWeb(this);
4836 r = _ContainerImpl::OnDetachingFromMainTree();
4837 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4844 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4850 case _CONTROL_ROTATION_0:
4853 case _CONTROL_ROTATION_90:
4856 case _CONTROL_ROTATION_180:
4859 case _CONTROL_ROTATION_270:
4865 ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree);
4870 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4872 _ContainerImpl::OnChangeLayout(orientation);
4874 if (__pColorPicker.get())
4876 __pColorPicker->ChangeLayout(orientation);
4879 HideFormDataWindow();
4881 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4882 _WebNotification* pWebNotification = null;
4884 while (pEnum->MoveNext() == E_SUCCESS)
4886 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4887 pWebNotification->OnChangeLayout();
4893 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4895 _WebManager* pWebManager = _WebManager::GetInstance();
4896 if (IsVisible() == true)
4898 pWebManager->SetActiveWeb(this);
4899 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4903 pWebManager->RemoveActiveWeb(this);
4904 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4910 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4912 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
4916 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4917 __pCertConfirmPopup.reset();
4919 case ID_PROMPT_POPUP_CLOSE:
4920 __pPromptPopup.reset();
4922 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
4923 __pUserMediaConfirmPopup.reset();
4925 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
4926 __pGeolocationConfirmPopup.reset();
4928 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
4929 __pNotificationConfirmPopup.reset();
4931 case ID_USER_SCRIPT_ALERT_CLOSE:
4932 __pScriptAlertConfirmPopup.reset();
4934 case ID_USER_SCRIPT_CONFIRM_CLOSE:
4935 __pScriptConfirmPopup.reset();
4946 _WebImpl::GetDownloadHandler(void) const
4948 return __pWebDownloadHandler.get();
4953 _WebImpl::HideColorPicker(void)
4955 __pColorPicker.reset();
4964 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4966 result r = E_SUCCESS;
4968 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4969 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4971 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4973 r = pColorHadler->Construct(colorVal, this);
4974 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4976 __pColorPicker = std::move(pColorHadler);
4978 r = __pColorPicker->ShowPopup();
4979 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4983 color = __pColorPicker->GetColor();
4989 __pColorPicker.reset();
4998 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
5000 result r = E_SUCCESS;
5002 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
5003 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5005 r = pInputPicker->Construct(String(inputValue), inputType, this);
5006 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5008 __pDatePicker = std::move(pInputPicker);
5010 r = __pDatePicker->ShowPopup();
5011 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5015 dateStr = __pDatePicker->GetDate();
5021 __pDatePicker.reset();
5030 _WebImpl::GetInstance(Web* pWeb)
5032 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5037 _WebImpl::GetInstance(const Web* pWeb)
5039 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5044 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5046 int checkReturn = 0;
5048 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5051 if( checkmime == true)
5053 table = CUSTOM_CONTENT_TABLE_NAME;
5057 table = CUSTOM_PROTOCOL_TABLE_NAME;
5060 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5061 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5062 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5064 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5066 result r = db.Construct(handlerPath, "r+", null);
5067 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5069 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"'"));
5070 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5074 r = pEnum->MoveNext();
5075 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5076 r = pEnum->GetIntAt(0, checkReturn);
5077 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5089 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5093 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5096 if( checkmime == true)
5098 table = CUSTOM_CONTENT_TABLE_NAME;
5102 table = CUSTOM_PROTOCOL_TABLE_NAME;
5105 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5106 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5107 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5109 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5111 result r = db.Construct(handlerPath, "r+", null);
5112 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5114 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"'"));
5115 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5119 r = pEnum->MoveNext();
5120 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5121 r = pEnum->GetIntAt(0, checkId);
5122 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5124 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5125 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5127 r = pDeleteStmt->BindInt(0, checkId);
5128 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5130 db.BeginTransaction();
5132 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5134 db.CommitTransaction();
5141 const Tizen::Base::String
5142 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5144 if (originUri == L"" || currentUri == L"")
5149 result r = E_SUCCESS;
5152 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5153 String originReplace(originUri);
5154 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5158 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5159 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5161 r = currentUri.SubString(0, found + 1, baseUri);
5162 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5164 r = db.Construct(handlerPath, "r+", null);
5165 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5167 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5168 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5172 while (pEnum->MoveNext() == E_SUCCESS)
5177 String originScheme;
5179 r = pEnum->GetStringAt(0, protocol);
5180 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5182 r = pEnum->GetStringAt(1, queryUrl);
5183 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5185 r = pEnum->GetIntAt(2, allow);
5186 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5193 String protocolScheme(protocol + L":");
5195 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5196 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5198 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5200 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5202 r = originReplace.Replace(originScheme, "");
5203 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5205 queryUrl.Replace("%s", originReplace, 0);
5206 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5218 const Tizen::Base::String
5219 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5221 if (originUri == L"" || currentUri == L"" || mime == L"")
5226 result r = E_SUCCESS;
5229 String originUrlStr = originUri;
5230 const String replaceStr = L"%s";
5232 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5233 String table(CUSTOM_CONTENT_TABLE_NAME);
5237 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5238 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5240 r = currentUri.SubString(0, found + 1, baseUri);
5241 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5243 r = db.Construct(handlerPath, "r+", null);
5244 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5246 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5250 r = pEnum->MoveNext();
5251 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5252 r = pEnum->GetIntAt(0, allow);
5253 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5254 r = pEnum->GetStringAt(1, contentUrl);
5255 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5263 if (contentUrl != L"")
5265 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5266 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5278 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5280 __pFormDataList = pFormDataList;
5285 _WebImpl::IsFormDataWindowVisible(void) const
5287 return __isFormDataVisible;
5292 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5294 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5296 if (__isFormDataVisible)
5298 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5299 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5303 __pFormDataWindow.reset();
5305 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5306 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5308 result r = pFormDataWindow->Construct(rect, this, pWebView);
5309 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5311 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5312 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5314 r = pFormDataWindow->LaunchFormDataWindow();
5315 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5317 __pFormDataWindow = std::move(pFormDataWindow);
5318 __isFormDataVisible = true;
5326 _WebImpl::HideFormDataWindow(bool delWindow)
5330 __pFormDataWindow.reset();
5333 __isFormDataVisible = false;
5338 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5340 __webNotificationList.Remove(*pWebNotification);
5345 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5347 __webNotificationList.Add(pWebNotification);
5351 }}} // Tizen::Web::Controls