2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_WebImpl.cpp
20 * @brief The file contains the definition of _WebImpl class.
22 * The file contains the definition of _WebImpl class.
24 #include <Ecore_IMF_Evas.h>
25 #include <Ecore_Evas.h>
26 #include <elm_config.h>
29 #include <ewk_popup_menu_item.h>
30 #include <libsoup/soup-status.h>
32 #include <FAppAppControl.h>
33 #include <FAppIAppControlListener.h>
34 #include <FBaseColAllElementsDeleter.h>
35 #include <FBaseColHashMapT.h>
36 #include <FBaseRtMutex.h>
37 #include <FBaseRtMutexGuard.h>
38 #include <FBaseSysLog.h>
39 #include <FBaseUtilUri.h>
40 #include <FCntDownloadRequest.h>
41 #include <FGrpColor.h>
42 #include <FGrpPoint.h>
43 #include <FGrpRectangle.h>
44 #include <FIoDbEnumerator.h>
45 #include <FIoDbStatement.h>
47 #include <FMediaImage.h>
48 #include <FMediaImageTypes.h>
49 #include <FNetHttpHttpHeader.h>
50 #include <FSysVibrator.h>
51 #include <FUiControl.h>
52 #include <FUiCtrlKeypad.h>
53 #include <FWebCtrlHitElementResult.h>
54 #include <FWebCtrlITextSearchListener.h>
55 #include <FWebCtrlIWebDownloadListener.h>
56 #include <FWebCtrlIWebUiEventListener.h>
57 #include <FWebCtrlIWebUiEventListenerF.h>
58 #include <FWebCtrlIWebKeypadEventListener.h>
59 #include <FWebCtrlIJavaScriptBridge.h>
60 #include <FWebCtrlPageNavigationList.h>
61 #include <FWebCtrlAuthenticationChallenge.h>
62 #include <FWebCtrlWeb.h>
63 #include <FWebCtrlWebSetting.h>
64 #include <FWebHistoryItem.h>
65 #include <FWebJsonJsonObject.h>
66 #include <FWebJsonJsonParser.h>
67 #include <FWebJsonJsonString.h>
68 #include <FApp_AppControlImpl.h>
69 #include <FApp_AppControlManager.h>
70 #include <FApp_AppInfo.h>
71 #include <FApp_AppManagerImpl.h>
72 #include <FBase_StringConverter.h>
73 #include <FCnt_DownloadManagerImpl.h>
74 #include <FGrp_CoordinateSystem.h>
75 #include <FGrp_Screen.h>
76 #include <FIo_DatabaseImpl.h>
77 #include <FIo_NormalFile.h>
78 #include <FSys_VibratorImpl.h>
79 #include <FUi_Control.h>
80 #include <FUi_CoordinateSystemUtils.h>
81 #include <FUi_EcoreEvasMgr.h>
82 #include <FUi_EcoreEvas.h>
83 #include <FUi_ResourceSizeInfo.h>
84 #include <FUi_Window.h>
85 #include <FUiAnim_EflNode.h>
86 #include <FUiAnim_VisualElement.h>
87 #include <FUiCtrl_FooterImpl.h>
88 #include <FUiCtrl_Form.h>
89 #include "FWeb_HistoryItemImpl.h"
90 #include "FWebCtrl_AppControlListener.h"
91 #include "FWebCtrl_AuthConfirmPopup.h"
92 #include "FWebCtrl_AuthenticationChallengeImpl.h"
93 #include "FWebCtrl_EflWebkit.h"
94 #include "FWebCtrl_FormDataWindow.h"
95 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
96 #include "FWebCtrl_HitElementResultImpl.h"
97 #include "FWebCtrl_InputPickerPopup.h"
98 #include "FWebCtrl_WebNotification.h"
99 #include "FWebCtrl_PageNavigationListImpl.h"
100 #include "FWebCtrl_PromptPopup.h"
101 #include "FWebCtrl_SelectBox.h"
102 #include "FWebCtrl_Utility.h"
103 #include "FWebCtrl_Web.h"
104 #include "FWebCtrl_WebDataHandler.h"
105 #include "FWebCtrl_WebEvent.h"
106 #include "FWebCtrl_WebEventArg.h"
107 #include "FWebCtrl_WebImpl.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 MessageBox messageBox;
366 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
367 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
371 messageBox.SetOwner(&pImpl->GetPublic());
373 r = messageBox.ShowAndWait(modalResult);
374 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
376 if (modalResult == MSGBOX_RESULT_OK)
378 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
382 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
390 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
392 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
394 result r = E_SUCCESS;
395 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
396 String msg(pMessage);
397 String defVal(pDefaultValue);
399 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
400 SysTryCatch(NID_WEB_CTRL, pPromptPopup.get(), , E_OUT_OF_MEMORY, "Memory allocation failed.");
402 r = pPromptPopup->Construct(msg, defVal, pView);
403 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
405 pPromptPopup->SetOwner(&pImpl->GetPublic());
407 r = pPromptPopup->ShowPopup();
408 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
410 pPromptPopup.release();
415 ewk_view_javascript_prompt_reply(pView, null);
422 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
424 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
425 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
426 SysAssertf(pImpl && pPolicy, "Failed to request");
428 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
430 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
432 if (pImpl->IsCertificateRequested())
434 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
438 result r = E_SUCCESS;
440 std::unique_ptr<DbEnumerator> pEnum;
442 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
443 String table(CERTIFICATE_TABLE_NAME);
446 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
448 r = db.Construct(certificatePath, "r", null);
449 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
451 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
454 r = pEnum->MoveNext();
455 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
458 r = pEnum->GetIntAt(0, allow);
459 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
461 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
463 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
464 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
468 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
469 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
472 pImpl->SetCertificateRequested(true);
475 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
476 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
478 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
479 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
488 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
489 pImpl->SetCertificateConfirmed(false);
490 pImpl->SetCertificateRequested(true);
495 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
497 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
498 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
499 SysAssertf(pImpl && pChallenge, "Failed to request");
501 result r = E_SUCCESS;
503 r = pImpl->HttpAuthenticationRequested(pChallenge);
504 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
508 ewk_auth_challenge_credential_cancel(pChallenge);
509 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
514 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
516 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
517 SysAssertf(pImpl , "Failed to request");
519 if (pImpl->GetLoadingListener())
521 result r = E_SUCCESS;
523 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
524 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
526 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
527 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
533 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
535 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
536 SysAssertf(pImpl , "Failed to request");
538 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
540 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
541 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
543 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
544 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
551 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
553 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
554 SysAssertf(pImpl , "Failed to request");
556 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
558 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
559 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
561 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
562 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
569 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
571 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
572 SysAssertf(pImpl , "Failed to request");
574 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
576 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
577 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
579 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
580 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
586 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
588 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
589 SysAssertf(pImpl , "Failed to request");
591 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
593 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
594 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
596 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
597 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
604 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
606 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
607 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
608 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
610 if (pImpl->GetSetting().IsGeolocationEnabled())
612 result r = E_SUCCESS;
614 std::unique_ptr<DbEnumerator> pEnum;
616 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
617 String table(GEOLOCATION_TABLE_NAME);
620 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
621 String origin = _Utility::CreateOrigin(pSecurityOrigin);
623 r = db.Construct(geolocationPath, "r", null);
624 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
626 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
629 r = pEnum->MoveNext();
630 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
633 r = pEnum->GetIntAt(0, permission);
634 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
636 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
638 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
642 ewk_geolocation_permission_request_suspend(pPermissionRequest);
644 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
645 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
652 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
657 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
659 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
660 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
661 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
663 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
664 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
668 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
673 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
675 result r = E_SUCCESS;
676 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
678 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
679 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
681 ewk_notification_permission_request_suspend(pPermissionRequest);
683 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
684 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
688 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
693 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
695 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
696 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
697 SysAssertf(pImpl && pNotification, "Failed to request");
699 result r = E_SUCCESS;
700 Ewk_Context* pContext = ewk_view_context_get(pView);
701 SysAssertf(pContext, "Failed to get webkit instance.");
702 uint64_t notificationId = ewk_notification_id_get(pNotification);
704 //ewk_notification_security_origin_get(pNotification)
706 const char* text = ewk_notification_body_get(pNotification);
707 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
709 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
710 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
712 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
713 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
715 pNotificationWindow->SetText(String(text));
716 pNotificationWindow->LaunchNotification();
717 pNotificationWindow.release();
719 ewk_notification_showed(pContext, notificationId);
724 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
726 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
727 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
728 SysAssertf(pImpl && pNotificationID, "Failed to request");
730 //ToDo : Where is ewk API for cancel operation?
735 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
737 result r = E_SUCCESS;
738 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
739 SysAssertf(pImpl, "Failed to request");
741 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
742 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
747 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
749 int checkHandler = 0;
750 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
751 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
752 SysAssertf(pImpl && pHandlerData, "Failed to request");
754 checkHandler = pImpl->SearchHandler(pHandlerData, false);
755 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
756 switch (checkHandler)
761 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
764 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
767 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
775 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
777 result r = E_SUCCESS;
778 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
779 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
780 SysAssertf(pImpl && pHandlerData, "Failed to request");
782 r = pImpl->UnregistrationHandler(pHandlerData, false);
783 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
788 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
790 result r = E_SUCCESS;
791 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
792 SysAssertf(pImpl, "Failed to request");
794 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
795 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
800 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
802 int checkHandler = 0;
803 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
804 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
805 SysAssertf(pImpl && pHandlerData, "Failed to request");
807 checkHandler = pImpl->SearchHandler(pHandlerData, true);
808 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
810 switch (checkHandler)
815 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
818 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
821 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
830 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
832 result r = E_SUCCESS;
833 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
834 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
835 SysAssertf(pImpl && pHandlerData, "Failed to request");
837 r = pImpl->UnregistrationHandler(pHandlerData, true);
838 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
843 OnVibrationRequested(uint64_t duration, void* pUserData)
845 result r = E_SUCCESS;
847 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
848 SysAssertf(pImpl, "Failed to request");
850 r = pImpl->VibrationRequested(duration);
851 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
856 OnVibrationCanceled(void* pUserData)
858 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
859 SysAssertf(pImpl, "Failed to request");
861 pImpl->VibrationCanceled();
866 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
868 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
869 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
870 SysAssertf(pImpl && pPolicy, "Failed to request");
872 String url(ewk_policy_decision_url_get(pPolicy));
873 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
875 if (url == L"about:blank")
877 ewk_policy_decision_use(pPolicy);
881 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
882 && !pImpl->IsRedirectRequested())
884 pImpl->SetCertificateRequested(false);
886 if (pImpl->GetTextSearchListener())
888 pImpl->DisableAsyncSearch();
891 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
892 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
894 switch (ewkNavigationType)
896 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
897 navigationType = WEB_NAVIGATION_LINK_CLICKED;
899 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
900 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
902 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
903 navigationType = WEB_NAVIGATION_BACKFORWARD;
905 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
906 navigationType = WEB_NAVIGATION_RELOAD;
908 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
909 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
911 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
912 navigationType = WEB_NAVIGATION_OTHER;
918 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
920 ewk_policy_decision_ignore(pPolicy);
926 String currentUrl(pImpl->GetUrl());
927 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
928 if (redirectUrl != L"")
930 pImpl->LoadUrl(redirectUrl);
931 ewk_policy_decision_ignore(pPolicy);
939 String uriScheme(uri.GetScheme());
940 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
942 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
944 ewk_policy_decision_ignore(pPolicy);
946 if (uriScheme == L"")
951 result r = E_SUCCESS;
953 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
955 if (uriScheme == L"rtsp")
957 eventType = WEB_EVENT_REQUEST_RTSP;
959 else if (uriScheme == L"mailto")
961 eventType = WEB_EVENT_REQUEST_EMAIL;
963 else if (uriScheme == L"tel")
965 eventType = WEB_EVENT_REQUEST_TEL;
967 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
969 eventType = WEB_EVENT_REQUEST_SMS;
971 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
973 eventType = WEB_EVENT_REQUEST_MMS;
976 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
977 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
979 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
980 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
986 ewk_policy_decision_use(pPolicy);
991 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
993 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
994 SysAssertf(pImpl, "Failed to request");
996 if (pImpl->GetLoadingListener())
998 result r = E_SUCCESS;
1000 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
1001 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1003 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1004 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1005 pEventArg.release();
1011 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1013 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1014 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1015 SysAssertf(pImpl, "Failed to request");
1017 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1019 if (pImpl->GetLoadingListener())
1021 result r = E_SUCCESS;
1023 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1024 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1025 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1027 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1028 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1029 pPageTitle.release();
1031 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1032 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1033 pEventArg.release();
1039 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1041 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1042 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1043 SysAssertf(pImpl, "Failed to request");
1045 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1047 if (pImpl->GetLoadingListener())
1049 result r = E_SUCCESS;
1051 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1052 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1053 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1055 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1056 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1057 pProgressPercentage.release();
1059 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1060 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1061 pEventArg.release();
1067 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1069 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1070 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1071 SysAssertf(pImpl && pPolicy, "Failed to request");
1073 result r = E_SUCCESS;
1075 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1076 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1077 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1078 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1080 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1082 String url(ewk_policy_decision_url_get(pPolicy));
1085 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1087 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1089 DecisionPolicy policy;
1090 HttpHeader httpHeader;
1092 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1094 pImpl->SetRedirectRequested(true);
1098 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1099 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1101 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1102 pImpl->SetPolicyDecision(policy);
1105 switch (pImpl->GetPolicyDecision())
1107 case WEB_DECISION_CONTINUE:
1109 String currentUrl(pImpl->GetUrl());
1110 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1111 if (redirectUrl != L"")
1113 pImpl->LoadUrl(redirectUrl);
1114 ewk_policy_decision_ignore(pPolicy);
1119 if (pImpl->IsMimeSupported(mime) || mime == L"")
1126 SysLog(NID_WEB_CTRL, "Launch native app to handle the mime");
1128 ewk_policy_decision_ignore(pPolicy);
1130 AppControl* pAppControl = null;
1131 _SelectBox selectBox;
1133 int selectedIndex = 0;
1135 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
1139 appCount = pList->GetCount();
1142 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
1143 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1145 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1146 for (int i = 0; i < appCount; i++)
1148 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
1149 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1151 String text = pAppControl->GetAppName();
1152 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
1154 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1156 r = selectBox.ShowAndWait(selectedIndex);
1157 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1159 if (selectedIndex == 0) //download
1161 RequestId reqId = 0;
1162 DownloadRequest request(pUrl);
1164 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1165 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1167 r = pManagerImpl->Start(request, reqId);
1168 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1170 else if (selectedIndex != -1) // -1 for cancel
1172 String path("path");
1173 String pathVal(pUrl);
1176 r = dataList.Construct();
1177 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1179 r = dataList.Add(path, pathVal);
1180 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1182 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
1183 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1185 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
1186 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1188 r = pAcImpl->Start(null, null, &dataList, null);
1189 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1196 case WEB_DECISION_DOWNLOAD:
1198 ewk_policy_decision_ignore(pPolicy);
1200 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1201 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1203 Ewk_Context* pContext = ewk_view_context_get(pView);
1204 SysAssertf(pContext, "Failed to get webkit instance.");
1206 pDownloadHandler->StartDownload(pUrl);
1210 case WEB_DECISION_IGNORE:
1212 ewk_policy_decision_ignore(pPolicy);
1222 ewk_policy_decision_use(pPolicy);
1227 ewk_policy_decision_ignore(pPolicy);
1232 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1234 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1235 SysAssertf(pImpl, "Failed to request");
1237 if (pImpl->IsRedirectRequested())
1239 pImpl->SetRedirectRequested(false);
1242 if (pImpl->IsLoadingErrorOccurred())
1244 pImpl->SetLoadingErrorOccurred(false);
1245 evas_object_smart_callback_call(pView, "load,finished", NULL);
1251 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1253 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1254 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1255 SysAssertf(pImpl && pErrorData, "Failed to request");
1257 int code = ewk_error_code_get(pErrorData);
1258 const char* pDescription = ewk_error_description_get(pErrorData);
1260 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1262 pImpl->SetLoadingErrorOccurred(true);
1265 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1267 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1270 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1271 evas_object_smart_callback_call(pView, "load,stop", NULL);
1275 if (pImpl->GetLoadingListener())
1277 result r = E_SUCCESS;
1279 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1280 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1288 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1290 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1291 SysAssertf(pImpl, "Failed to request");
1293 if (pImpl->GetLoadingListener())
1295 result r = E_SUCCESS;
1297 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1298 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1300 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1301 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1302 pEventArg.release();
1309 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1311 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1312 SysAssertf(pImpl, "Failed to request");
1314 if (pImpl->GetLoadingListener())
1316 result r = E_SUCCESS;
1318 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1319 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1321 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1322 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1323 pEventArg.release();
1330 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1332 evas_object_focus_set(pView, EINA_FALSE);
1337 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1339 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1340 SysAssertf(pImpl, "Failed to request");
1342 if (pImpl->GetLoadingListener())
1344 result r = E_SUCCESS;
1346 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1347 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1349 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1350 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1351 pEventArg.release();
1358 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1360 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1361 SysAssertf(pUrl && pImpl != null, "Failed to request");
1363 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1368 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1370 result r = E_SUCCESS;
1372 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1373 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1375 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1376 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1377 pEventArg.release();
1384 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1386 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1387 SysAssertf(pImpl, "Failed to request");
1389 if (pImpl->GetUiEventListener())
1391 result r = E_SUCCESS;
1393 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1394 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1396 if (pImpl->GetUiEventListenerF())
1398 result r = E_SUCCESS;
1400 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1401 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1407 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1409 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1410 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1411 SysAssertf(pParentImpl && pChildView, "Failed to request");
1413 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1414 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1415 if (pUserUiListener)
1417 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1420 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1421 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1423 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1424 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1427 if (pUserUiListenerF)
1429 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1432 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1433 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1435 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1436 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1443 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1445 result r = E_SUCCESS;
1447 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1448 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1450 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1451 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1452 pEventArg.release();
1459 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1461 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1462 SysAssertf(pChildImpl, "Failed to request");
1464 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1465 if (pParentImpl == null)
1470 if (pParentImpl->GetUiEventListener())
1472 result r = E_SUCCESS;
1474 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1475 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1477 if (pParentImpl->GetUiEventListenerF())
1479 result r = E_SUCCESS;
1481 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1482 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1488 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1490 result r = E_SUCCESS;
1492 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1493 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1494 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1496 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1497 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1498 pPreventTrigger.release();
1500 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1501 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1502 pEventArg.release();
1509 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1511 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1512 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1513 SysAssertf(pImpl && pTrigger, "Failed to request");
1515 if (pImpl->GetUiEventListener())
1517 result r = E_SUCCESS;
1519 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1520 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1522 if (pImpl->GetUiEventListenerF())
1524 result r = E_SUCCESS;
1526 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1527 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1533 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1535 result r = E_SUCCESS;
1537 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1538 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1539 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1541 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1543 if ((endPoint->x != 0) && (endPoint->y != 0))
1545 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1546 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1548 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1549 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1550 startPoint.release();
1552 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1553 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1556 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1557 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1558 pEventArg.release();
1566 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1568 result r = E_SUCCESS;
1570 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1571 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1573 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1575 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1577 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1579 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1580 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1582 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1583 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1584 startPoint.release();
1586 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1587 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1590 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1591 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1592 pEventArg.release();
1600 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1602 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1603 SysAssertf(pImpl, "Failed to request");
1605 if (pImpl->GetUiEventListener())
1607 result r = E_SUCCESS;
1609 r = FireWebPageBlockSelectedEvent(pImpl);
1610 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1612 if (pImpl->GetUiEventListenerF())
1614 result r = E_SUCCESS;
1616 r = FireWebPageBlockSelectedEventF(pImpl);
1617 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1623 OnWebPageBlockSelectedByOrientation(void* pUserData, Evas_Object* pView, void* pEventInfo)
1625 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1626 SysAssertf(pImpl, "Failed to request");
1628 if (!pImpl->IsOrientationChanged())
1633 pImpl->SetOrientationChanged(false);
1635 int orientation = 0;
1636 _ControlRotation rotation = _ControlManager::GetInstance()->GetOrientationStatus();
1639 case _CONTROL_ROTATION_0:
1642 case _CONTROL_ROTATION_90:
1645 case _CONTROL_ROTATION_180:
1648 case _CONTROL_ROTATION_270:
1652 ewk_view_orientation_send(pView, orientation);
1654 OnWebPageBlockSelected(pUserData, pView, pEventInfo);
1659 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1661 String isMultipleSelection(L"single");
1662 result r = E_SUCCESS;
1665 String mode(L"selectionType");
1666 String type(L"type");
1667 _AppControlImpl* pMediaAppControlImpl = null;
1670 String fileType = L"all";
1674 isMultipleSelection.Append(L"multiple");
1677 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1678 SysTryReturn(NID_WEB_CTRL, pMediaAppControl.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1680 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1681 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1683 pMediaListener->Construct(pView, pMediaAppControl.get());
1685 itemCount = eina_list_count(pAcceptTypes);
1689 String item((char*)eina_list_nth(pAcceptTypes, 0));
1690 if (item.StartsWith("image/",0))
1692 fileType = L"image";
1694 else if (item.StartsWith("audio/",0))
1696 fileType = L"audio";
1698 else if (item.StartsWith("video/",0))
1700 fileType = L"video";
1704 r = dataList.Construct();
1705 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1707 r = dataList.Add(mode, isMultipleSelection);
1708 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1710 r = dataList.Add(type, fileType);
1711 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1713 pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl.get());
1714 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1715 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1717 pMediaListener.release();
1718 pMediaAppControl.release();
1723 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1729 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1731 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1732 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1733 SysAssertf(pImpl && pJsonText, "Failed to request");
1735 result r = E_SUCCESS;
1737 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1739 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1740 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1742 r = pEventArg->Construct(pJsonText);
1743 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1745 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1746 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1747 pEventArg.release();
1752 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1754 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1755 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1756 SysAssertf(pImpl && pEinaRect, "Failed to request");
1758 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1760 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1761 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1763 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1765 if (rect.height == 0)
1770 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1773 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1775 pImpl->SetFooterVisibleState(true);
1776 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1779 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1782 if (pImpl->GetWebKeypadEventListener())
1784 if (pImpl->IsKeypadVisible() == true)
1786 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1788 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1793 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1796 pImpl->SetKeypadVisibleState(true);
1797 pImpl->SetPreviousKeypadBounds(rect);
1801 result r = pImpl->SetFullScreenKeypad();
1802 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1808 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1810 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1811 SysAssertf(pImpl, "Failed to request");
1813 if (pImpl->GetWebKeypadEventListener())
1815 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1821 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1823 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1824 SysAssertf(pImpl, "Failed to request");
1826 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1829 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1831 pImpl->SetFooterVisibleState(false);
1832 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1835 pFormCore->DeflateClientRectHeight(0);
1838 if (pImpl->GetWebKeypadEventListener())
1840 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1843 pImpl->SetKeypadVisibleState(false);
1848 OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info)
1850 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1851 SysAssertf(pImpl, "Failed to request");
1853 if (pImpl->IsKeypadOpened() == true)
1855 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1856 SysAssertf(pWebCore, "Failed to get Web core object");
1858 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1860 pImpl->SetKeypadOpened(false);
1866 OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo)
1868 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1869 SysAssertf(pImpl, "Failed to request");
1871 if (pImpl->IsKeypadOpened() == true)
1873 pImpl->SetKeypadOpened(false);
1879 OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha)
1881 SysAssertf(pSmartData, "invalid smartdata");
1882 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1883 SysAssertf(pWebImpl, "Failed to get Impl");
1885 result r = E_SUCCESS;
1887 if (pWebImpl->GetColorpicker())
1894 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1895 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1897 byte r1, g1, b1, a1;
1898 color.GetColorComponents(r1, g1, b1, a1);
1899 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1906 OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData)
1908 SysAssertf(pSmartData, "invalid smartdata");
1910 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1911 SysAssertf(pWebImpl, "Failed to get Impl");
1913 return pWebImpl->HideColorPicker();
1918 OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1920 SysAssertf(pSmartData, "Failed to request");
1921 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1922 SysAssertf(pWebImpl, "Failed to get Impl");
1924 result r = E_SUCCESS;
1926 if (pWebImpl->GetDatepicker())
1928 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1935 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1936 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1938 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1939 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1941 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1948 OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1950 SysAssertf(pSmartData, "Failed to request");
1952 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1953 SysAssertf(pWebImpl, "Failed to get Impl");
1955 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1956 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1963 OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData)
1965 SysAssertf(pSmartData, "invalid smartdata");
1967 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1968 SysAssertf(pWebImpl, "Failed to get Impl");
1970 result r = pWebImpl->ClearSelectBoxPopup();
1971 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1978 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1980 SysAssertf(pSmartData, "invalid smartdata");
1982 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1983 SysAssertf(pWebImpl, "Failed to get Impl");
1985 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1986 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1993 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1995 SysAssertf(pSmartData, "Failed to request");
1997 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1998 SysAssertf(pWebImpl, "Failed to get Impl");
2000 Rectangle windowRect(x, y, w, h);
2001 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
2002 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2009 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
2011 SysAssertf(pSmartData, "Failed to request");
2013 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2014 SysAssertf(pWebImpl, "Failed to get Impl");
2016 if (pWebImpl->IsFormDataWindowVisible())
2018 pWebImpl->HideFormDataWindow();
2026 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
2028 SysAssertf(pSmartData, "Failed to request");
2030 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2031 SysAssertf(pWebImpl, "Failed to get Impl");
2033 pWebImpl->SetFormDataList(pDataList);
2040 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
2042 SysAssertf(pSmartData, "Failed to request");
2044 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2045 SysAssertf(pWebImpl, "Failed to get Impl");
2047 if (pWebImpl->IsFormDataWindowVisible())
2059 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2061 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2062 SysAssertf(pPresenter && !pError, "Failed to request");
2064 bool ret = EINA_TRUE;
2068 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2070 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2074 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2083 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2085 pPresenter->EndAsyncProcess(ret);
2090 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2092 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2093 SysAssertf(pPresenter, "Failed to request");
2095 String result(pResult);
2096 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2098 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2099 if (pImpl && pImpl->IsPresenterAlived(pPresenter))
2101 pPresenter->EndAsyncProcess(result);
2107 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2109 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2110 SysAssertf(pImpl, "Failed to request");
2112 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2113 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2115 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2119 pWebPresenter->EndAsyncProcess(*pTotalCount);
2123 if (pImpl->GetTextSearchListener())
2125 result r = E_SUCCESS;
2129 if (*pTotalCount > 0)
2131 ordinal = pImpl->GetAsyncSearchOrdinal();
2132 pImpl->SetAsyncSearchResult(*pTotalCount);
2135 if (pImpl->GetPendingAsyncSearchCount() > 0)
2140 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2141 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2142 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2143 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2145 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2146 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2149 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2150 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2153 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2154 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2155 pEventArg.release();
2161 class _JsBridgeHashCodeProvider
2162 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2165 _JsBridgeHashCodeProvider(){}
2166 virtual ~_JsBridgeHashCodeProvider(void) {}
2169 int GetHashCode(const Tizen::Base::String& obj) const
2171 return obj.GetHashCode();
2177 //Comparer implementation
2178 class _JsBridgeComparer
2179 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2182 _JsBridgeComparer(){}
2183 virtual ~_JsBridgeComparer(void) {}
2186 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2203 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2204 : _ContainerImpl(pWeb, pCore)
2205 , __isFooterVisible(false)
2206 , __isKeypadVisible(false)
2207 , __isKeypadOpened(false)
2208 , __isLoadingErrorOccurred(false)
2209 , __isRedirectRequested(false)
2210 , __isCertificateRequested(false)
2211 , __isCertificateConfirmed(false)
2212 , __isOrientationChanged(false)
2213 , __isFormDataVisible(false)
2214 , __keypadBounds(0, 0, 0, 0)
2216 , __pUserLoadingListener(null)
2217 , __pUserUiListener(null)
2218 , __pUserUiListenerF(null)
2219 , __pUserKeypadEventListener(null)
2220 , __pTextSearchListener(null)
2222 , __pJsBridgeList(null)
2223 , __pJsProvider(null)
2224 , __pJsComparer(null)
2225 , __pWebDownloadHandler(null)
2227 , __pAuthChallenge(null)
2228 , __pAuthPopup(null)
2229 , __pUserConfirmPopup(null)
2230 , __pCertConfirmPopup(null)
2231 , __pSelectBox(null)
2232 , __pDatePicker(null)
2233 , __pColorPicker(null)
2234 , __pFormDataWindow(null)
2236 , __policy(WEB_DECISION_CONTINUE)
2237 , __defaultUserAgent(L"")
2238 , __pFormDataList(null)
2240 __textSearch.__searchAll = false;
2241 __textSearch.__searchForward = true;
2242 __textSearch.__caseSensitive = false;
2243 __textSearch.__pending = 0;
2244 __textSearch.__currentIndex = 1;
2245 __textSearch.__totalCount = -1;
2246 __textSearch.__text = L"";
2250 _WebImpl::~_WebImpl()
2252 RemoveEventListenerCallback();
2253 ClearCertificateDb();
2258 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2260 result r = E_SUCCESS;
2262 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2263 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2265 _Web* pCore = _Web::CreateWebN();
2266 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2268 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2270 r = CheckConstruction(pCore, pImpl);
2271 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2273 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2274 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2276 r = pImpl->Construct();
2277 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2289 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2291 result r = E_SUCCESS;
2293 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2294 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2296 _Web* pCore = _Web::CreateWebN();
2297 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2299 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2301 r = CheckConstruction(pCore, pImpl);
2302 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2304 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2305 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2307 r = pImpl->Construct();
2308 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2320 _WebImpl::Construct(void)
2322 result r = E_SUCCESS;
2324 r = __mutex.Create();
2325 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2327 r = __textSearch.__searchQueue.Construct();
2328 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2330 r = __callbackList.Construct();
2331 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2333 r = InitJsBridgeList();
2334 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2337 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2339 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2340 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2347 _WebImpl::InitializeSetting(void)
2349 result r = E_SUCCESS;
2351 WebSetting* pWebSetting = __pWebCore->GetSetting();
2352 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2354 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2355 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2356 SetZoomLevel(pWebSettingImpl->GetZoomLevel());
2358 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2360 r = SetSetting(*pWebSetting);
2361 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2363 SetEventListenerCallback();
2370 _WebImpl::IsLayoutable(void) const
2377 _WebImpl::InitWebEvent(void)
2379 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2380 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2382 return __pWebEvent->Construct(*this);
2387 _WebImpl::GetWebEvent(void) const
2389 return __pWebEvent.get();
2394 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2396 Eina_Hash* pHttpHeader = null;
2398 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2399 if (pFieldNameList.get())
2401 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2402 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2404 int count = pFieldNameList->GetCount();
2406 for (int i = 0; i < count; i++)
2408 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2409 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2411 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2412 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2414 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2415 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2417 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2419 Eina_Bool ret = false;
2421 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2422 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2424 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2425 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2427 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2428 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2435 eina_hash_free(pHttpHeader);
2442 _WebImpl::LoadUrl(const String& url) const
2444 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2445 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2447 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2454 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2456 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2457 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2459 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2461 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2463 eina_hash_free(pHttpHeader);
2470 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2472 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2473 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2475 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2477 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2479 eina_hash_free(pHttpHeader);
2486 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2488 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2490 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2491 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2492 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2493 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2495 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2502 _WebImpl::Pause(void)
2504 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2509 _WebImpl::Resume(void)
2511 ewk_view_resume(__pWebCore->GetWebNativeNode());
2516 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2518 __pSelectBox.reset();
2520 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2522 result r = E_SUCCESS;
2524 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2525 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2527 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2528 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2530 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2531 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2533 __pSelectBox = std::move(pSelectBox);
2535 __pSelectBox->SetOwner(&GetPublic());
2537 return __pSelectBox->ShowPopup();
2542 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2544 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2546 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2551 _WebImpl::ClearSelectBoxPopup(void)
2553 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2555 __pSelectBox.reset();
2562 _WebImpl::GetDatepicker(void)
2564 _InputPickerPopup* pInputPicker =null;
2567 pInputPicker = __pDatePicker.get();
2569 return pInputPicker;
2574 _WebImpl::GetColorpicker(void)
2576 _InputPickerPopup* pInputPicker =null;
2579 pInputPicker = __pColorPicker.get();
2581 return pInputPicker;
2586 _WebImpl::CanGoBack(void) const
2588 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2593 _WebImpl::CanGoForward(void) const
2595 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2600 _WebImpl::GoBack(void) const
2602 ewk_view_back(__pWebCore->GetWebNativeNode());
2607 _WebImpl::GoForward(void) const
2609 ewk_view_forward(__pWebCore->GetWebNativeNode());
2614 _WebImpl::GetUrl(void) const
2616 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2621 _WebImpl::GetTitle(void) const
2623 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2628 _WebImpl::StopLoading(void) const
2630 ewk_view_stop(__pWebCore->GetWebNativeNode());
2635 _WebImpl::Reload(void) const
2637 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
2642 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2644 if (scriptCode.GetLength() == 0)
2649 result r = E_SUCCESS;
2651 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2652 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2654 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
2655 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2657 r = __callbackList.Add(pPresenter.get());
2658 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2660 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, pPresenter.get());
2662 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2663 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2664 pPresenter->WaitAsyncProcess(*pResult.get());
2666 r = __callbackList.Remove(*pPresenter.get());
2667 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2668 pPresenter.release();
2670 return pResult.release();
2675 _WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
2677 return __callbackList.Contains(*pPresenter);
2682 _WebImpl::SetZoomLevel(float level)
2684 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);
2686 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2693 _WebImpl::GetZoomLevel(void) const
2695 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2699 const PageNavigationList*
2700 _WebImpl::GetBackForwardListN(void) const
2702 result r = E_SUCCESS;
2704 _PageNavigationListImpl* pNavigationListImpl = null;
2705 _HistoryItemImpl* pHistoryItemImpl = null;
2707 std::unique_ptr<PageNavigationList> pNavigationList;
2708 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2711 int forwardCount = 0;
2716 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2717 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2719 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2720 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2722 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2723 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2725 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2726 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2728 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2729 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2731 r = pHistoryList->Construct();
2732 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2734 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2735 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2736 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2738 for (int i = -backCount; i < forwardCount + 1; i++)
2740 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2741 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2743 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2744 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2746 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2747 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2749 url = ewk_history_item_uri_get(pEwkItem);
2750 title = ewk_history_item_title_get(pEwkItem);
2751 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2753 pHistoryItemImpl->SetHistoryItem(url, title);
2755 r = pHistoryList->Add(*pHistoryItem.get());
2756 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2757 pHistoryItem.release();
2760 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2762 ewk_history_free(pEwkHistoryList);
2764 return pNavigationList.release();
2767 ewk_history_free(pEwkHistoryList);
2774 _WebImpl::SearchText(const String& text, bool searchForward)
2776 result r = E_SUCCESS;
2778 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2782 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2785 _WebPresenter presenter;
2786 presenter.InitAsyncProcess();
2788 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2789 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2792 presenter.WaitAsyncProcess(result);
2794 return static_cast < bool >(result);
2799 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2801 result r = E_SUCCESS;
2803 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2807 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2810 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2811 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2818 _WebImpl::SearchNextAsync(bool searchForward)
2820 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2821 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2822 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2824 result r = E_SUCCESS;
2826 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2828 if (!__textSearch.__caseSensitive)
2830 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2835 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2838 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2839 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2846 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2848 MutexGuard lock(__mutex);
2850 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2851 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2856 if (__textSearch.__searchAll)
2858 DisableAsyncSearch();
2860 __textSearch.__searchQueue.Enqueue(this);
2861 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2863 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2864 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2868 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2870 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2874 case SEARCH_ALL_ASYNC:
2875 __textSearch.__searchAll = true;
2876 __textSearch.__text = text;
2877 __textSearch.__searchForward = true;
2878 __textSearch.__caseSensitive = caseSensitive;
2879 __textSearch.__totalCount = -1;
2880 __textSearch.__currentIndex = 1;
2882 __textSearch.__searchQueue.Enqueue(this);
2883 __textSearch.__searchQueue.Enqueue(this);
2885 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2886 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2889 case SEARCH_NEXT_ASYNC:
2890 __textSearch.__searchForward = searchForward;
2892 CalculateAsyncSearchOrdinal();
2894 __textSearch.__searchQueue.Enqueue(this);
2896 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2908 _WebImpl::SetAsyncSearchResult(int totalCount)
2910 __textSearch.__totalCount = totalCount;
2915 _WebImpl::GetSearchPresenter(void)
2917 MutexGuard lock(__mutex);
2919 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2924 _WebImpl::GetPendingAsyncSearchCount(void) const
2926 return __textSearch.__searchQueue.GetCount();
2931 _WebImpl::CalculateAsyncSearchOrdinal(void)
2933 if (__textSearch.__searchForward)
2935 __textSearch.__currentIndex++;
2939 __textSearch.__currentIndex--;
2945 _WebImpl::GetAsyncSearchOrdinal(void) const
2947 return __textSearch.__currentIndex;
2952 _WebImpl::DisableAsyncSearch(void)
2954 __textSearch.__searchAll = false;
2959 _WebImpl::SetSetting(const WebSetting& setting)
2961 if (__pWebCore->GetWebNativeNode())
2963 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2964 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2965 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2967 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2968 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2970 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2972 switch (setting.GetCacheControl())
2974 case WEB_CACHE_VALIDATED:
2975 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2978 case WEB_CACHE_IGNORE:
2979 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2986 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2988 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2992 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2995 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2997 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2999 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
3001 if (__defaultUserAgent != setting.GetUserAgent())
3003 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
3004 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3006 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
3009 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
3011 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
3013 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3015 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3018 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3020 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3021 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3022 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3023 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3024 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3025 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3026 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3027 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3028 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3029 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3030 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3031 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3032 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3039 _WebImpl::GetSetting(void) const
3041 return *__pWebCore->GetSetting();
3045 const HitElementResult*
3046 _WebImpl::GetElementByPointN(const Point& point) const
3048 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3052 const HitElementResult*
3053 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3055 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));
3057 result r = E_SUCCESS;
3059 _HitElementResultImpl* pHitElementResultImpl = null;
3061 std::unique_ptr<HitElementResult> pHitElementResult;
3062 std::unique_ptr<Bitmap> pImage;
3063 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3065 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3067 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3068 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3070 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3071 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3072 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3073 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3074 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3076 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3078 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3079 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3081 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3082 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3084 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3090 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3091 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3092 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3093 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3095 r = buf.Construct(imageLength);
3096 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3098 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3099 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3103 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3104 // webkit support types such as ico and vp8 additionally
3105 if (strcmp(pExtension, "gif") == 0)
3107 format = IMG_FORMAT_GIF;
3109 else if (strcmp(pExtension, "jpg") == 0)
3111 format = IMG_FORMAT_JPG;
3113 else if (strcmp(pExtension, "png") == 0)
3115 format = IMG_FORMAT_PNG;
3117 else if (strcmp(pExtension, "bmp") == 0)
3119 format = IMG_FORMAT_BMP;
3123 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3127 r = image.Construct();
3128 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3130 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3131 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3136 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3137 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3139 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3140 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3142 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3143 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3146 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3148 ewk_hit_test_free(pEwkHitTest);
3150 return pHitElementResult.release();
3153 ewk_hit_test_free(pEwkHitTest);
3160 _WebImpl::IsLoading(void) const
3162 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3164 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3176 _WebImpl::GetTextFromBlock(void) const
3178 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3183 _WebImpl::IsPrivateBrowsingEnabled(void) const
3185 if (__pWebCore->GetWebNativeNode() == null)
3187 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3190 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3191 SysAssertf(pSettings, "Failed to get webkit instance.");
3193 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3198 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3200 if (__pWebCore->GetWebNativeNode() == null)
3202 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3206 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3207 SysAssertf(pSettings, "Failed to get webkit instance.");
3209 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3214 _WebImpl::ClearHistory(void)
3216 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3221 _WebImpl::ClearCache(void)
3223 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3224 SysAssertf(pContext, "Failed to get webkit instance.");
3226 ewk_context_cache_clear(pContext);
3231 _WebImpl::ClearCookie(void)
3233 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3234 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3235 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3237 ewk_cookie_manager_cookies_clear(pCookieManager);
3242 _WebImpl::ClearFormData(void)
3244 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3245 SysAssertf(pContext, "Failed to get webkit instance.");
3247 ewk_context_form_candidate_data_clear(pContext);
3252 _WebImpl::ClearLoginFormData(void)
3254 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3255 SysAssertf(pContext, "Failed to get webkit instance.");
3257 ewk_context_form_password_data_clear(pContext);
3262 _WebImpl::IsCookieEnabled(void) const
3264 if (__pWebCore->GetWebNativeNode() == null)
3266 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3269 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3270 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3271 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3273 _WebPresenter presenter;
3274 presenter.InitAsyncProcess();
3276 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3278 bool result = false;
3279 presenter.WaitAsyncProcess(result);
3286 _WebImpl::SetCookieEnabled(bool enable)
3288 if (__pWebCore->GetWebNativeNode() == null)
3290 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3295 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3296 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3297 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3301 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3305 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3306 ewk_cookie_manager_cookies_clear(pCookieManager);
3312 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3314 result r = E_SUCCESS;
3316 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3317 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3320 String fileExtension = File::GetFileExtension(filePath);
3321 int pathLength = filePath.GetLength();
3324 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3326 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3327 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3328 r = filePath.SubString(0, index + 1, dirPath);
3329 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3331 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3332 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3336 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3338 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3342 Evas_Coord contentsWidth;
3343 Evas_Coord contentsHeight;
3345 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3346 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3354 _WebImpl::IsMimeSupported(const String& mime) const
3356 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3357 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3359 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3364 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3366 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3371 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3373 __pUserUiListener = pUiEventListener;
3378 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3380 __pUserUiListenerF = pUiEventListener;
3385 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3387 __pUserKeypadEventListener = pKeypadEventListener;
3392 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3394 if (__pWebDownloadHandler.get() == null)
3396 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3397 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3400 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3401 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3406 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3408 __pTextSearchListener = pTextSearchListener;
3413 _WebImpl::SetScrollEnabled(bool enable)
3415 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3420 _WebImpl::IsScrollEnabled(void) const
3422 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3427 _WebImpl::InitJsBridgeList(void)
3429 result r = E_SUCCESS;
3431 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3432 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3434 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3435 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3437 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3438 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3440 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3441 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3443 __pJsBridgeList = std::move(pJsBridgeList);
3450 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3452 result r = E_SUCCESS;
3454 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3455 String key(pJsBridge->GetName());
3457 r = __pJsBridgeList->Add(key, pJsBridge);
3458 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3465 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3467 result r = E_SUCCESS;
3469 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3470 String key(pJsBridge->GetName());
3472 r = __pJsBridgeList->Remove(key);
3473 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3480 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3482 result r = E_SUCCESS;
3484 IJsonValue* pJsonValue = null;
3485 IJavaScriptBridge* pJsBridge = null;
3487 String key(L"name");
3489 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3490 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));
3492 r = pJsonObject->GetValue(&key, pJsonValue);
3493 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3495 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3496 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3498 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3499 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3506 _WebImpl::GetLoadingListener(void) const
3508 return __pUserLoadingListener;
3512 IWebUiEventListener*
3513 _WebImpl::GetUiEventListener(void) const
3515 return __pUserUiListener;
3519 IWebUiEventListenerF*
3520 _WebImpl::GetUiEventListenerF(void) const
3522 return __pUserUiListenerF;
3526 IWebKeypadEventListener*
3527 _WebImpl::GetWebKeypadEventListener(void) const
3529 return __pUserKeypadEventListener;
3533 ITextSearchListener*
3534 _WebImpl::GetTextSearchListener(void) const
3536 return __pTextSearchListener;
3541 _WebImpl::SetEventListenerCallback(void) const
3543 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3546 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3547 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3549 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3550 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3552 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3553 SysAssertf(pSmartData, "Failed to request");
3555 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3556 SysAssertf(pSmart, "Failed to request");
3558 pSmart->popup_menu_show = OnSelectBoxRequested;
3559 pSmart->popup_menu_hide = OnSelectBoxClosed;
3560 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3562 pSmart->input_picker_show = OnDatePickerProviderRequested;
3563 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3564 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3566 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3567 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3568 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3569 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3571 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3573 // add loading event callbacks for ILoadingListener
3574 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3575 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3577 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3578 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3579 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3580 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3581 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3582 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3583 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3584 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3585 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3587 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3589 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3591 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3592 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3593 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3595 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3596 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3598 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3600 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3601 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3602 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3604 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3606 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3607 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3608 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3610 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3611 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3612 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3614 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3615 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3616 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3618 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3619 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3620 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3621 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3623 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3624 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3626 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3627 evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this);
3629 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3630 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3631 SysAssertf(pContext, "Failed to get webkit instance.");
3632 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3633 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3635 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3636 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3637 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3638 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3640 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3646 _WebImpl::RemoveEventListenerCallback(void) const
3648 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3651 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3652 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3654 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3655 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3657 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3658 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3660 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3661 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3662 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3663 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3664 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3665 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3666 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3667 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3669 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3671 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3673 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3674 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3675 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3677 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3678 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3680 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3682 ewk_view_javascript_alert_callback_set(null, null, null);
3683 ewk_view_javascript_prompt_callback_set(null, null, null);
3684 ewk_view_javascript_confirm_callback_set(null, null, null);
3686 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3688 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3689 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3690 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3692 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3693 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3694 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3695 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3696 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3697 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3699 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3700 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3701 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3703 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3705 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3706 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3708 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3709 evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation);
3711 ewk_view_open_panel_callback_set(null, null, null);
3712 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3713 SysAssertf(pContext, "Failed to get webkit instance.");
3714 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3716 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3717 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3718 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3719 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3721 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3727 _WebImpl::ClearCertificateDb(void)
3729 result r = E_SUCCESS;
3731 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3732 String table(CERTIFICATE_TABLE_NAME);
3735 r = db.Construct(certificatePath, "r+", null);
3736 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3738 db.BeginTransaction();
3740 r = db.ExecuteSql(L"Delete From " + table, true);
3741 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3743 db.CommitTransaction();
3748 db.RollbackTransaction();
3753 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3755 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3760 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3762 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3764 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3765 SysAssertf(pSmartData, "Failed to request");
3767 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3769 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3772 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3774 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3775 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3777 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3779 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3781 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3785 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3786 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3789 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3794 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3801 _WebImpl::ReleaseBlock(void)
3803 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3808 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3810 FloatPoint tempStartPoint;
3811 FloatPoint tempEndPoint;
3813 GetBlockRange(tempStartPoint, tempEndPoint);
3815 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3816 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3821 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3823 Eina_Rectangle leftHandle;
3824 Eina_Rectangle rightHandle;
3826 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3828 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3829 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3830 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3831 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3833 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3835 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3836 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3842 _WebImpl::GetFaviconN(void) const
3844 result r = E_SUCCESS;
3846 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3848 Evas* pEvas = evas_object_evas_get(pView);
3849 Ewk_Context* pContext = ewk_view_context_get(pView);
3850 SysAssertf(pEvas && pContext, "Failed to request");
3852 const char* pUrl = ewk_view_url_get(pView);
3854 Tizen::Graphics::BufferInfo bufferInfo;
3855 Tizen::Base::ByteBuffer byteBuffer;
3857 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3858 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3860 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3866 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3867 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3869 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3871 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3872 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3874 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3875 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3877 return pBitmapImage.release();
3883 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3885 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3890 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3892 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3897 _WebImpl::GetScrollPosition(void) const
3901 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3908 _WebImpl::GetPageSize(void) const
3910 Evas_Coord width = 0;
3911 Evas_Coord height = 0;
3913 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3915 Dimension size(static_cast< int >(width), static_cast< int >(height));
3922 _WebImpl::SetLoadingErrorOccurred(bool arg)
3924 __isLoadingErrorOccurred = arg;
3929 _WebImpl::IsLoadingErrorOccurred(void) const
3931 return __isLoadingErrorOccurred;
3936 _WebImpl::SetRedirectRequested(bool arg)
3938 __isRedirectRequested = arg;
3943 _WebImpl::IsRedirectRequested(void) const
3945 return __isRedirectRequested;
3950 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3957 _WebImpl::GetPolicyDecision(void) const
3964 _WebImpl::SetCertificateRequested(bool arg)
3966 __isCertificateRequested = arg;
3971 _WebImpl::IsCertificateRequested(void) const
3973 return __isCertificateRequested;
3978 _WebImpl::SetCertificateConfirmed(bool arg)
3980 __isCertificateConfirmed = arg;
3985 _WebImpl::IsCertificateConfirmed(void) const
3987 return __isCertificateConfirmed;
3992 _WebImpl::SetOrientationChanged(bool arg)
3994 __isOrientationChanged = arg;
3999 _WebImpl::IsOrientationChanged(void) const
4001 return __isOrientationChanged;
4006 _WebImpl::LaunchAppControl(const IEventArg& arg)
4008 result r = E_SUCCESS;
4010 IEventArg* pArg = const_cast< IEventArg* >(&arg);
4011 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
4012 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
4014 String operationId(L"");
4015 String uriPattern(pWebEventArg->GetEventMessage());
4016 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
4018 switch (pWebEventArg->GetEventType())
4020 case WEB_EVENT_REQUEST_RTSP:
4024 int uriLength = uriPattern.GetLength();
4027 operationId = L"http://tizen.org/appcontrol/operation/view";
4029 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
4030 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4032 r = uriPattern.SubString(index + 1, ext);
4033 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4035 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
4036 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4038 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
4039 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4043 case WEB_EVENT_REQUEST_TEL:
4045 operationId = L"http://tizen.org/appcontrol/operation/dial";
4048 case WEB_EVENT_REQUEST_EMAIL:
4050 case WEB_EVENT_REQUEST_SMS:
4052 case WEB_EVENT_REQUEST_MMS:
4054 operationId = L"http://tizen.org/appcontrol/operation/compose";
4057 case WEB_EVENT_REQUEST_UNKNOWN:
4059 operationId = L"http://tizen.org/appcontrol/operation/view";
4067 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
4068 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4075 _WebImpl::SetFullScreenKeypad(void)
4077 result r = E_SUCCESS;
4079 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4080 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4082 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4083 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4085 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4086 pKeypad->SetText(text);
4088 r = pKeypad->SetShowState(true);
4089 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4091 r = pKeypad->Show();
4092 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4094 pKeypad->AddTextEventListener(*this);
4096 __pKeypad = std::move(pKeypad);
4103 _WebImpl::RemoveFullScreenKeypad(void)
4105 __pKeypad->RemoveTextEventListener(*this);
4112 _WebImpl::IsFooterVisible(void) const
4114 return __isFooterVisible;
4119 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4121 __isFooterVisible = isFooterVisible;
4126 _WebImpl::IsKeypadVisible(void) const
4128 return __isKeypadVisible;
4133 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4135 __isKeypadVisible = isKeypadVisible;
4140 _WebImpl::IsKeypadOpened(void) const
4142 return __isKeypadOpened;
4146 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4148 __isKeypadOpened = isKeypadOpened;
4153 _WebImpl::GetPreviousKeypadBounds(void) const
4155 return __keypadBounds;
4160 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4162 __keypadBounds = bounds;
4167 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4169 RemoveFullScreenKeypad();
4174 _WebImpl::OnTextValueChanged(const Control& source)
4176 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4178 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4180 RemoveFullScreenKeypad();
4185 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4187 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4188 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4190 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4191 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4193 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4194 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4196 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4203 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4205 result r = E_SUCCESS;
4207 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4208 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4210 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4212 ILoadingListener* pLoadingListner = GetLoadingListener();
4213 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4215 switch (pEventArg->GetEventType())
4217 case WEB_EVENT_LOADINGLISTENER_STARTED:
4219 pLoadingListner->OnLoadingStarted();
4223 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4225 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4226 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4228 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4232 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4234 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4235 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4237 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4241 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4243 pLoadingListner->OnLoadingCanceled();
4247 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4249 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4250 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4252 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4253 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4255 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4257 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4261 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4263 pLoadingListner->OnLoadingCompleted();
4267 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4269 pLoadingListner->OnHttpAuthenticationCanceled();
4273 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4275 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4276 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4280 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4296 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4298 result r = E_SUCCESS;
4300 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4301 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4303 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4305 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4306 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4308 switch (pEventArg->GetEventType())
4310 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4312 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4313 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4315 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4319 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4321 pWebDownloadListener->OnWebDataDownloadCompleted();
4325 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4327 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4328 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4330 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4332 pWebDownloadListener->OnWebDownloadFailed(errorType);
4347 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4349 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4350 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4352 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4354 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4356 switch (pEventArg->GetEventType())
4358 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4360 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4362 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4363 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4365 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4366 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4368 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4372 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4374 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4376 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4380 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4382 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4384 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4388 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4390 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4392 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4393 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4395 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4410 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4412 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4413 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4415 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4417 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4419 switch (pEventArg->GetEventType())
4421 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4423 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4425 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4426 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4428 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4429 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4431 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4435 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4437 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4439 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4443 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4445 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4447 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4451 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4453 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4455 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4456 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4458 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4473 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4475 result r = E_SUCCESS;
4477 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4478 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4480 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4482 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4483 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4485 switch (pEventArg->GetEventType())
4487 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4489 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4490 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4492 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4493 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4495 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4510 _WebImpl::VibrationRequested(uint64_t duration)
4512 result r = E_SUCCESS;
4514 __pVibrator.reset();
4516 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4517 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4519 r = pVibrator->Construct();
4520 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4522 __pVibrator = std::move(pVibrator);
4524 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4526 r = __pVibrator->Start(&pattern, 1, 1);
4527 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4534 _WebImpl::VibrationCanceled(void)
4536 __pVibrator.reset();
4541 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4543 result r = E_SUCCESS;
4545 String host(ewk_auth_challenge_url_get(pChallenge));
4546 String realm(ewk_auth_challenge_realm_get(pChallenge));
4548 __pAuthChallenge.reset();
4550 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4551 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4553 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4554 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4556 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4557 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4559 __pAuthChallenge = std::move(pAuthChallenge);
4561 ewk_auth_challenge_suspend(pChallenge);
4562 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4564 __pAuthChallenge.release();
4568 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4569 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4577 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4579 result r = E_SUCCESS;
4581 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4582 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4584 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4585 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4587 __pAuthPopup = std::move(pAuthPopup);
4589 int modalResult = 0;
4591 __pAuthPopup->SetOwner(&GetPublic());
4593 r = __pAuthPopup->ShowAndWait(modalResult);
4594 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4597 __pAuthPopup.reset();
4604 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4606 result r = E_SUCCESS;
4608 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4609 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4611 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4612 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4614 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4616 int modalResult = 0;
4618 __pCertConfirmPopup->SetOwner(&GetPublic());
4620 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4621 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4623 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4625 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4629 __pCertConfirmPopup.reset();
4635 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4637 result r = E_SUCCESS;
4639 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4640 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4642 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
4643 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4645 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4647 int modalResult = 0;
4649 __pUserConfirmPopup->SetOwner(&GetPublic());
4651 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4652 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4655 __pUserConfirmPopup.reset();
4661 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4663 result r = E_SUCCESS;
4665 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4666 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4668 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
4669 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4671 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4673 __pUserConfirmPopup->SetOwner(&GetPublic());
4675 r = __pUserConfirmPopup->ShowPopup();
4676 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4678 __pUserConfirmPopup.release();
4683 __pUserConfirmPopup.reset();
4690 _WebImpl::GetParentFormCore(_Control* pControlCore)
4693 _Form* pFormCore = null;
4695 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4696 if (!pParentControlCore)
4701 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4707 return GetParentFormCore(pParentControlCore);
4712 _WebImpl::OnFocusGained(const _ControlImpl& source)
4719 _WebImpl::OnFocusLost(const _ControlImpl& source)
4721 if(IsKeypadVisible() == true)
4723 SetKeypadOpened(true);
4725 SetKeypadVisibleState(false);
4728 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4735 _WebImpl::HasValidNativeNode(void) const
4737 if (__pWebCore && __pWebCore->GetWebNativeNode())
4747 _WebImpl::OnPreAttachedToMainTree(void)
4749 result r = E_SUCCESS;
4751 r = __pWebCore->InitializeWebNativeNode();
4752 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4754 r = InitializeSetting();
4755 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4757 r = _ContainerImpl::OnPreAttachedToMainTree();
4758 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4765 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4767 _ContainerImpl::OnChangeLayout(orientation);
4769 if (__pColorPicker.get())
4771 __pColorPicker->ChangeLayout(orientation);
4774 HideFormDataWindow();
4776 __isOrientationChanged = true;
4781 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4783 if (IsVisible() == true)
4785 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4789 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4795 _WebImpl::GetDownloadHandler(void) const
4797 return __pWebDownloadHandler.get();
4802 _WebImpl::HideColorPicker(void)
4804 __pColorPicker.reset();
4811 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4813 result r = E_SUCCESS;
4815 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4816 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4818 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4820 r = pColorHadler->Construct(colorVal, this);
4821 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4823 __pColorPicker = std::move(pColorHadler);
4825 r = __pColorPicker->ShowPopup();
4826 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4828 color = __pColorPicker->GetColor();
4833 __pColorPicker.reset();
4840 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4842 result r = E_SUCCESS;
4844 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4845 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4847 r = pInputPicker->Construct(String(inputValue), inputType, this);
4848 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4850 __pDatePicker = std::move(pInputPicker);
4852 r = __pDatePicker->ShowPopup();
4853 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4855 dateStr = __pDatePicker->GetDate();
4858 __pDatePicker.reset();
4865 _WebImpl::GetInstance(Web* pWeb)
4867 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4872 _WebImpl::GetInstance(const Web* pWeb)
4874 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4879 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4881 int checkReturn = 0;
4883 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4886 if( checkmime == true)
4888 table = CUSTOM_CONTENT_TABLE_NAME;
4892 table = CUSTOM_PROTOCOL_TABLE_NAME;
4895 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4896 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4897 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4899 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4901 result r = db.Construct(handlerPath, "r+", null);
4902 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4904 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"'"));
4905 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4909 r = pEnum->MoveNext();
4910 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4911 r = pEnum->GetIntAt(0, checkReturn);
4912 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4924 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4928 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4931 if( checkmime == true)
4933 table = CUSTOM_CONTENT_TABLE_NAME;
4937 table = CUSTOM_PROTOCOL_TABLE_NAME;
4940 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4941 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4942 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4944 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4946 result r = db.Construct(handlerPath, "r+", null);
4947 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4949 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"'"));
4950 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4954 r = pEnum->MoveNext();
4955 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4956 r = pEnum->GetIntAt(0, checkId);
4957 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4959 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
4960 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4962 r = pDeleteStmt->BindInt(0, checkId);
4963 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4965 db.BeginTransaction();
4967 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
4969 db.CommitTransaction();
4976 const Tizen::Base::String
4977 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
4979 if (originUri == L"" || currentUri == L"")
4984 result r = E_SUCCESS;
4987 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4988 String originReplace(originUri);
4989 String table(CUSTOM_PROTOCOL_TABLE_NAME);
4993 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4994 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4996 r = currentUri.SubString(0, found + 1, baseUri);
4997 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4999 r = db.Construct(handlerPath, "r+", null);
5000 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5002 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5003 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5007 while (pEnum->MoveNext() == E_SUCCESS)
5012 String originScheme;
5014 r = pEnum->GetStringAt(0, protocol);
5015 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5017 r = pEnum->GetStringAt(1, queryUrl);
5018 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5020 r = pEnum->GetIntAt(2, allow);
5021 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5028 String protocolScheme(protocol + L":");
5030 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5031 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5033 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5035 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5037 r = originReplace.Replace(originScheme, "");
5038 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5040 queryUrl.Replace("%s", originReplace, 0);
5041 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5053 const Tizen::Base::String
5054 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5056 if (originUri == L"" || currentUri == L"" || mime == L"")
5061 result r = E_SUCCESS;
5064 String originUrlStr = originUri;
5065 const String replaceStr = L"%s";
5067 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5068 String table(CUSTOM_CONTENT_TABLE_NAME);
5072 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5073 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5075 r = currentUri.SubString(0, found + 1, baseUri);
5076 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5078 r = db.Construct(handlerPath, "r+", null);
5079 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5081 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5085 r = pEnum->MoveNext();
5086 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5087 r = pEnum->GetIntAt(0, allow);
5088 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5089 r = pEnum->GetStringAt(1, contentUrl);
5090 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5098 if (contentUrl != L"")
5100 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5101 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5113 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5115 __pFormDataList = pFormDataList;
5120 _WebImpl::IsFormDataWindowVisible(void) const
5122 return __isFormDataVisible;
5127 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5129 Point absPoint(windowRect.x, windowRect.y);
5131 Point relPoint = __pWebCore->GetRelativeCoordinate(absPoint);
5133 Rectangle rect(relPoint.x, relPoint.y, windowRect.width, windowRect.height);
5135 if (__isFormDataVisible)
5137 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5138 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5142 __pFormDataWindow.reset();
5144 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5145 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5147 result r = pFormDataWindow->Construct(rect, this, pWebView);
5148 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5150 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5151 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5153 r = pFormDataWindow->LaunchFormDataWindow();
5154 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5156 __pFormDataWindow = std::move(pFormDataWindow);
5157 __isFormDataVisible = true;
5165 _WebImpl::HideFormDataWindow(bool delWindow)
5169 __pFormDataWindow.reset();
5172 __isFormDataVisible = false;
5176 }}} // Tizen::Web::Controls