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);
1264 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1265 pImpl->SetLoadingErrorOccurred(true);
1268 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1269 evas_object_smart_callback_call(pView, "load,finished", NULL);
1272 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1273 pImpl->SetLoadingErrorOccurred(true);
1274 evas_object_smart_callback_call(pView, "load,stop", NULL);
1278 pImpl->SetLoadingErrorOccurred(true);
1279 if (pImpl->GetLoadingListener())
1281 result r = E_SUCCESS;
1283 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1284 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1292 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1294 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1295 SysAssertf(pImpl, "Failed to request");
1297 if (pImpl->GetLoadingListener())
1299 result r = E_SUCCESS;
1301 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1302 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1304 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1305 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1306 pEventArg.release();
1313 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1315 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1316 SysAssertf(pImpl, "Failed to request");
1318 if (pImpl->GetLoadingListener())
1320 result r = E_SUCCESS;
1322 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1323 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1325 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1326 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1327 pEventArg.release();
1334 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1336 evas_object_focus_set(pView, EINA_FALSE);
1341 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1343 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1344 SysAssertf(pImpl, "Failed to request");
1346 if (pImpl->GetLoadingListener())
1348 result r = E_SUCCESS;
1350 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1351 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1353 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1354 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1355 pEventArg.release();
1362 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1364 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1365 SysAssertf(pUrl && pImpl != null, "Failed to request");
1367 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1372 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1374 result r = E_SUCCESS;
1376 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1377 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1379 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1380 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1381 pEventArg.release();
1388 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1390 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1391 SysAssertf(pImpl, "Failed to request");
1393 if (pImpl->GetUiEventListener())
1395 result r = E_SUCCESS;
1397 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1398 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1400 if (pImpl->GetUiEventListenerF())
1402 result r = E_SUCCESS;
1404 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1405 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1411 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1413 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1414 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1415 SysAssertf(pParentImpl && pChildView, "Failed to request");
1417 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1418 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1419 if (pUserUiListener)
1421 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1424 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1425 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1427 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1428 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1431 if (pUserUiListenerF)
1433 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1436 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1437 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1439 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1440 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1447 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1449 result r = E_SUCCESS;
1451 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1452 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1454 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1455 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1456 pEventArg.release();
1463 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1465 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1466 SysAssertf(pChildImpl, "Failed to request");
1468 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1469 if (pParentImpl == null)
1474 if (pParentImpl->GetUiEventListener())
1476 result r = E_SUCCESS;
1478 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1479 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1481 if (pParentImpl->GetUiEventListenerF())
1483 result r = E_SUCCESS;
1485 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1486 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1492 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1494 result r = E_SUCCESS;
1496 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1497 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1498 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1500 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1501 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1502 pPreventTrigger.release();
1504 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1505 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1506 pEventArg.release();
1513 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1515 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1516 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1517 SysAssertf(pImpl && pTrigger, "Failed to request");
1519 if (pImpl->GetUiEventListener())
1521 result r = E_SUCCESS;
1523 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1524 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1526 if (pImpl->GetUiEventListenerF())
1528 result r = E_SUCCESS;
1530 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1531 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1537 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1539 result r = E_SUCCESS;
1541 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1542 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1543 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1545 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1547 if ((endPoint->x != 0) && (endPoint->y != 0))
1549 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1550 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1552 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1553 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1554 startPoint.release();
1556 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1557 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1560 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1561 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1562 pEventArg.release();
1570 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1572 result r = E_SUCCESS;
1574 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1575 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1577 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1579 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1581 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1583 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1584 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1586 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1587 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1588 startPoint.release();
1590 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1591 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1594 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1595 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1596 pEventArg.release();
1604 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1606 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1607 SysAssertf(pImpl, "Failed to request");
1609 if (pImpl->GetUiEventListener())
1611 result r = E_SUCCESS;
1613 r = FireWebPageBlockSelectedEvent(pImpl);
1614 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1616 if (pImpl->GetUiEventListenerF())
1618 result r = E_SUCCESS;
1620 r = FireWebPageBlockSelectedEventF(pImpl);
1621 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1627 OnWebPageBlockSelectedByOrientation(void* pUserData, Evas_Object* pView, void* pEventInfo)
1629 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1630 SysAssertf(pImpl, "Failed to request");
1632 if (!pImpl->IsOrientationChanged())
1637 pImpl->SetOrientationChanged(false);
1639 int orientation = 0;
1640 _ControlRotation rotation = _ControlManager::GetInstance()->GetOrientationStatus();
1643 case _CONTROL_ROTATION_0:
1646 case _CONTROL_ROTATION_90:
1649 case _CONTROL_ROTATION_180:
1652 case _CONTROL_ROTATION_270:
1656 ewk_view_orientation_send(pView, orientation);
1658 OnWebPageBlockSelected(pUserData, pView, pEventInfo);
1663 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1665 String isMultipleSelection(L"single");
1666 result r = E_SUCCESS;
1669 String mode(L"selectionType");
1670 String type(L"type");
1671 _AppControlImpl* pMediaAppControlImpl = null;
1674 String fileType = L"all";
1678 isMultipleSelection.Append(L"multiple");
1681 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1682 SysTryReturn(NID_WEB_CTRL, pMediaAppControl.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1684 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1685 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1687 pMediaListener->Construct(pView, pMediaAppControl.get());
1689 itemCount = eina_list_count(pAcceptTypes);
1693 String item((char*)eina_list_nth(pAcceptTypes, 0));
1694 if (item.StartsWith("image/",0))
1696 fileType = L"image";
1698 else if (item.StartsWith("audio/",0))
1700 fileType = L"audio";
1702 else if (item.StartsWith("video/",0))
1704 fileType = L"video";
1708 r = dataList.Construct();
1709 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1711 r = dataList.Add(mode, isMultipleSelection);
1712 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1714 r = dataList.Add(type, fileType);
1715 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1717 pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl.get());
1718 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1719 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1721 pMediaListener.release();
1722 pMediaAppControl.release();
1727 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1733 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1735 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1736 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1737 SysAssertf(pImpl && pJsonText, "Failed to request");
1739 result r = E_SUCCESS;
1741 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1743 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1744 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1746 r = pEventArg->Construct(pJsonText);
1747 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1749 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1750 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1751 pEventArg.release();
1756 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1758 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1759 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1760 SysAssertf(pImpl && pEinaRect, "Failed to request");
1762 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1764 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1765 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1767 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1769 if (rect.height == 0)
1774 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1777 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1779 pImpl->SetFooterVisibleState(true);
1780 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1783 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1786 if (pImpl->GetWebKeypadEventListener())
1788 if (pImpl->IsKeypadVisible() == true)
1790 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1792 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1797 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1800 pImpl->SetKeypadVisibleState(true);
1801 pImpl->SetPreviousKeypadBounds(rect);
1805 result r = pImpl->SetFullScreenKeypad();
1806 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1812 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1814 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1815 SysAssertf(pImpl, "Failed to request");
1817 if (pImpl->GetWebKeypadEventListener())
1819 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1825 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1827 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1828 SysAssertf(pImpl, "Failed to request");
1830 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1833 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1835 pImpl->SetFooterVisibleState(false);
1836 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1839 pFormCore->DeflateClientRectHeight(0);
1842 if (pImpl->GetWebKeypadEventListener())
1844 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1847 pImpl->SetKeypadVisibleState(false);
1852 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1854 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1855 SysAssertf(pImpl, "Failed to request");
1857 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true)
1859 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1860 SysAssertf(pWebCore, "Failed to get Web core object");
1862 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1865 pImpl->SetKeypadOpened(false);
1870 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1872 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1873 SysAssertf(pImpl, "Failed to request");
1875 if (pImpl->IsKeypadOpened() == true)
1877 pImpl->SetKeypadOpened(false);
1879 pImpl->SetFocused();
1885 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1887 SysAssertf(pSmartData, "invalid smartdata");
1888 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1889 SysAssertf(pWebImpl, "Failed to get Impl");
1891 result r = E_SUCCESS;
1893 if (pWebImpl->GetColorpicker())
1900 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1901 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1903 byte r1, g1, b1, a1;
1904 color.GetColorComponents(r1, g1, b1, a1);
1905 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1912 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1914 SysAssertf(pSmartData, "invalid smartdata");
1916 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1917 SysAssertf(pWebImpl, "Failed to get Impl");
1919 return pWebImpl->HideColorPicker();
1924 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1926 SysAssertf(pSmartData, "Failed to request");
1927 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1928 SysAssertf(pWebImpl, "Failed to get Impl");
1930 result r = E_SUCCESS;
1932 if (pWebImpl->GetDatepicker())
1934 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1941 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1942 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1944 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1945 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1947 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1954 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1956 SysAssertf(pSmartData, "Failed to request");
1958 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1959 SysAssertf(pWebImpl, "Failed to get Impl");
1961 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1962 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1969 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1971 SysAssertf(pSmartData, "Failed to request");
1973 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1974 SysAssertf(pWebImpl, "Failed to get Impl");
1976 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1977 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1984 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1986 SysAssertf(pSmartData, "invalid smartdata");
1988 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1989 SysAssertf(pWebImpl, "Failed to get Impl");
1991 result r = pWebImpl->ClearSelectBoxPopup();
1992 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1999 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
2001 SysAssertf(pSmartData, "invalid smartdata");
2003 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2004 SysAssertf(pWebImpl, "Failed to get Impl");
2006 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
2007 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2014 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
2016 SysAssertf(pSmartData, "Failed to request");
2018 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2019 SysAssertf(pWebImpl, "Failed to get Impl");
2021 Rectangle windowRect(x, y, w, h);
2022 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
2023 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2030 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
2032 SysAssertf(pSmartData, "Failed to request");
2034 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2035 SysAssertf(pWebImpl, "Failed to get Impl");
2037 if (pWebImpl->IsFormDataWindowVisible())
2039 pWebImpl->HideFormDataWindow();
2047 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
2049 SysAssertf(pSmartData, "Failed to request");
2051 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2052 SysAssertf(pWebImpl, "Failed to get Impl");
2054 pWebImpl->SetFormDataList(pDataList);
2061 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
2063 SysAssertf(pSmartData, "Failed to request");
2065 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2066 SysAssertf(pWebImpl, "Failed to get Impl");
2068 if (pWebImpl->IsFormDataWindowVisible())
2080 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2082 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2083 SysAssertf(pPresenter && !pError, "Failed to request");
2085 bool ret = EINA_TRUE;
2089 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2091 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2095 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2104 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2106 pPresenter->EndAsyncProcess(ret);
2111 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2113 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2114 SysAssertf(pPresenter, "Failed to request");
2116 String result(pResult);
2117 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2119 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2120 if (pImpl && pImpl->IsPresenterAlived(pPresenter))
2122 pPresenter->EndAsyncProcess(result);
2128 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2130 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2131 SysAssertf(pImpl, "Failed to request");
2133 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2134 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2136 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2140 pWebPresenter->EndAsyncProcess(*pTotalCount);
2144 if (pImpl->GetTextSearchListener())
2146 result r = E_SUCCESS;
2150 if (*pTotalCount > 0)
2152 ordinal = pImpl->GetAsyncSearchOrdinal();
2153 pImpl->SetAsyncSearchResult(*pTotalCount);
2156 if (pImpl->GetPendingAsyncSearchCount() > 0)
2161 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2162 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2163 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2164 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2166 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2167 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2170 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2171 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2174 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2175 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2176 pEventArg.release();
2182 class _JsBridgeHashCodeProvider
2183 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2186 _JsBridgeHashCodeProvider(){}
2187 virtual ~_JsBridgeHashCodeProvider(void) {}
2190 int GetHashCode(const Tizen::Base::String& obj) const
2192 return obj.GetHashCode();
2198 //Comparer implementation
2199 class _JsBridgeComparer
2200 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2203 _JsBridgeComparer(){}
2204 virtual ~_JsBridgeComparer(void) {}
2207 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2224 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2225 : _ContainerImpl(pWeb, pCore)
2226 , __isFooterVisible(false)
2227 , __isKeypadVisible(false)
2228 , __isKeypadOpened(false)
2229 , __isLoadingErrorOccurred(false)
2230 , __isRedirectRequested(false)
2231 , __isCertificateRequested(false)
2232 , __isCertificateConfirmed(false)
2233 , __isOrientationChanged(false)
2234 , __isFormDataVisible(false)
2235 , __keypadBounds(0, 0, 0, 0)
2237 , __pUserLoadingListener(null)
2238 , __pUserUiListener(null)
2239 , __pUserUiListenerF(null)
2240 , __pUserKeypadEventListener(null)
2241 , __pTextSearchListener(null)
2243 , __pJsBridgeList(null)
2244 , __pJsProvider(null)
2245 , __pJsComparer(null)
2246 , __pWebDownloadHandler(null)
2248 , __pAuthChallenge(null)
2249 , __pAuthPopup(null)
2250 , __pUserConfirmPopup(null)
2251 , __pCertConfirmPopup(null)
2252 , __pSelectBox(null)
2253 , __pDatePicker(null)
2254 , __pColorPicker(null)
2255 , __pFormDataWindow(null)
2257 , __policy(WEB_DECISION_CONTINUE)
2258 , __defaultUserAgent(L"")
2259 , __pFormDataList(null)
2261 __textSearch.__searchAll = false;
2262 __textSearch.__searchForward = true;
2263 __textSearch.__caseSensitive = false;
2264 __textSearch.__pending = 0;
2265 __textSearch.__currentIndex = 1;
2266 __textSearch.__totalCount = -1;
2267 __textSearch.__text = L"";
2271 _WebImpl::~_WebImpl()
2273 RemoveEventListenerCallback();
2274 ClearCertificateDb();
2279 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2281 result r = E_SUCCESS;
2283 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2284 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2286 _Web* pCore = _Web::CreateWebN();
2287 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2289 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2291 r = CheckConstruction(pCore, pImpl);
2292 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2294 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2295 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2297 r = pImpl->Construct();
2298 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2310 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2312 result r = E_SUCCESS;
2314 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2315 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2317 _Web* pCore = _Web::CreateWebN();
2318 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2320 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2322 r = CheckConstruction(pCore, pImpl);
2323 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2325 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2326 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2328 r = pImpl->Construct();
2329 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2341 _WebImpl::Construct(void)
2343 result r = E_SUCCESS;
2345 r = __mutex.Create();
2346 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2348 r = __textSearch.__searchQueue.Construct();
2349 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2351 r = __callbackList.Construct();
2352 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2354 r = InitJsBridgeList();
2355 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2358 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2360 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2361 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2368 _WebImpl::InitializeSetting(void)
2370 result r = E_SUCCESS;
2372 WebSetting* pWebSetting = __pWebCore->GetSetting();
2373 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2375 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2376 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2378 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2380 r = SetSetting(*pWebSetting);
2381 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2383 SetEventListenerCallback();
2390 _WebImpl::IsLayoutable(void) const
2397 _WebImpl::InitWebEvent(void)
2399 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2400 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2402 return __pWebEvent->Construct(*this);
2407 _WebImpl::GetWebEvent(void) const
2409 return __pWebEvent.get();
2414 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2416 Eina_Hash* pHttpHeader = null;
2418 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2419 if (pFieldNameList.get())
2421 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2422 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2424 int count = pFieldNameList->GetCount();
2426 for (int i = 0; i < count; i++)
2428 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2429 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2431 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2432 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2434 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2435 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2437 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2439 Eina_Bool ret = false;
2441 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2442 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2444 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2445 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2447 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2448 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2455 eina_hash_free(pHttpHeader);
2462 _WebImpl::LoadUrl(const String& url) const
2464 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2465 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2467 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2474 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2476 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2477 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2479 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2481 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2483 eina_hash_free(pHttpHeader);
2490 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2492 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2493 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2495 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2497 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2499 eina_hash_free(pHttpHeader);
2506 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2508 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2510 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2511 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2512 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2513 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2515 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2522 _WebImpl::Pause(void)
2524 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2529 _WebImpl::Resume(void)
2531 ewk_view_resume(__pWebCore->GetWebNativeNode());
2536 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2538 __pSelectBox.reset();
2540 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2542 result r = E_SUCCESS;
2544 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2545 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2547 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2548 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2550 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2551 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2553 __pSelectBox = std::move(pSelectBox);
2555 __pSelectBox->SetOwner(&GetPublic());
2557 return __pSelectBox->ShowPopup();
2562 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2564 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2566 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2571 _WebImpl::ClearSelectBoxPopup(void)
2573 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2575 __pSelectBox.reset();
2582 _WebImpl::GetDatepicker(void)
2584 _InputPickerPopup* pInputPicker =null;
2587 pInputPicker = __pDatePicker.get();
2589 return pInputPicker;
2594 _WebImpl::GetColorpicker(void)
2596 _InputPickerPopup* pInputPicker =null;
2599 pInputPicker = __pColorPicker.get();
2601 return pInputPicker;
2606 _WebImpl::CanGoBack(void) const
2608 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2613 _WebImpl::CanGoForward(void) const
2615 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2620 _WebImpl::GoBack(void) const
2622 ewk_view_back(__pWebCore->GetWebNativeNode());
2627 _WebImpl::GoForward(void) const
2629 ewk_view_forward(__pWebCore->GetWebNativeNode());
2634 _WebImpl::GetUrl(void) const
2636 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2641 _WebImpl::GetTitle(void) const
2643 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2648 _WebImpl::StopLoading(void) const
2650 ewk_view_stop(__pWebCore->GetWebNativeNode());
2655 _WebImpl::Reload(void) const
2657 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
2662 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2664 if (scriptCode.GetLength() == 0)
2669 result r = E_SUCCESS;
2671 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2672 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2674 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
2675 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2677 r = __callbackList.Add(pPresenter.get());
2678 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2680 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, pPresenter.get());
2682 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2683 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2684 pPresenter->WaitAsyncProcess(*pResult.get());
2686 r = __callbackList.Remove(*pPresenter.get());
2687 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2688 pPresenter.release();
2690 return pResult.release();
2695 _WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
2697 return __callbackList.Contains(*pPresenter);
2702 _WebImpl::SetZoomLevel(float level)
2704 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);
2706 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2713 _WebImpl::GetZoomLevel(void) const
2715 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2719 const PageNavigationList*
2720 _WebImpl::GetBackForwardListN(void) const
2722 result r = E_SUCCESS;
2724 _PageNavigationListImpl* pNavigationListImpl = null;
2725 _HistoryItemImpl* pHistoryItemImpl = null;
2727 std::unique_ptr<PageNavigationList> pNavigationList;
2728 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2731 int forwardCount = 0;
2736 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2737 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2739 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2740 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2742 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2743 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2745 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2746 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2748 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2749 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2751 r = pHistoryList->Construct();
2752 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2754 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2755 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2756 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2758 for (int i = -backCount; i < forwardCount + 1; i++)
2760 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2761 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2763 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2764 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2766 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2767 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2769 url = ewk_history_item_uri_get(pEwkItem);
2770 title = ewk_history_item_title_get(pEwkItem);
2771 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2773 pHistoryItemImpl->SetHistoryItem(url, title);
2775 r = pHistoryList->Add(*pHistoryItem.get());
2776 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2777 pHistoryItem.release();
2780 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2782 ewk_history_free(pEwkHistoryList);
2784 return pNavigationList.release();
2787 ewk_history_free(pEwkHistoryList);
2794 _WebImpl::SearchText(const String& text, bool searchForward)
2796 result r = E_SUCCESS;
2798 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2802 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2805 _WebPresenter presenter;
2806 presenter.InitAsyncProcess();
2808 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2809 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2812 presenter.WaitAsyncProcess(result);
2814 return static_cast < bool >(result);
2819 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2821 result r = E_SUCCESS;
2823 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2827 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2830 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2831 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2838 _WebImpl::SearchNextAsync(bool searchForward)
2840 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2841 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2842 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2844 result r = E_SUCCESS;
2846 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2848 if (!__textSearch.__caseSensitive)
2850 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2855 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2858 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2859 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2866 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2868 MutexGuard lock(__mutex);
2870 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2871 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2876 if (__textSearch.__searchAll)
2878 DisableAsyncSearch();
2880 __textSearch.__searchQueue.Enqueue(this);
2881 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2883 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2884 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2888 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2890 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2894 case SEARCH_ALL_ASYNC:
2895 __textSearch.__searchAll = true;
2896 __textSearch.__text = text;
2897 __textSearch.__searchForward = true;
2898 __textSearch.__caseSensitive = caseSensitive;
2899 __textSearch.__totalCount = -1;
2900 __textSearch.__currentIndex = 1;
2902 __textSearch.__searchQueue.Enqueue(this);
2903 __textSearch.__searchQueue.Enqueue(this);
2905 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2906 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2909 case SEARCH_NEXT_ASYNC:
2910 __textSearch.__searchForward = searchForward;
2912 CalculateAsyncSearchOrdinal();
2914 __textSearch.__searchQueue.Enqueue(this);
2916 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2928 _WebImpl::SetAsyncSearchResult(int totalCount)
2930 __textSearch.__totalCount = totalCount;
2935 _WebImpl::GetSearchPresenter(void)
2937 MutexGuard lock(__mutex);
2939 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2944 _WebImpl::GetPendingAsyncSearchCount(void) const
2946 return __textSearch.__searchQueue.GetCount();
2951 _WebImpl::CalculateAsyncSearchOrdinal(void)
2953 if (__textSearch.__searchForward)
2955 __textSearch.__currentIndex++;
2959 __textSearch.__currentIndex--;
2965 _WebImpl::GetAsyncSearchOrdinal(void) const
2967 return __textSearch.__currentIndex;
2972 _WebImpl::DisableAsyncSearch(void)
2974 __textSearch.__searchAll = false;
2979 _WebImpl::SetSetting(const WebSetting& setting)
2981 if (__pWebCore->GetWebNativeNode())
2983 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2984 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2985 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2987 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2988 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2990 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2992 switch (setting.GetCacheControl())
2994 case WEB_CACHE_VALIDATED:
2995 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2998 case WEB_CACHE_IGNORE:
2999 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
3006 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
3008 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
3012 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
3015 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
3017 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
3019 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
3021 if (__defaultUserAgent != setting.GetUserAgent())
3023 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
3024 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3026 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
3029 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
3031 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
3033 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3035 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3038 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3040 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3041 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3042 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3043 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3044 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3045 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3046 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3047 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3048 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3049 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3050 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3051 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3052 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3059 _WebImpl::GetSetting(void) const
3061 return *__pWebCore->GetSetting();
3065 const HitElementResult*
3066 _WebImpl::GetElementByPointN(const Point& point) const
3068 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3072 const HitElementResult*
3073 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3075 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));
3077 result r = E_SUCCESS;
3079 _HitElementResultImpl* pHitElementResultImpl = null;
3081 std::unique_ptr<HitElementResult> pHitElementResult;
3082 std::unique_ptr<Bitmap> pImage;
3083 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3085 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3087 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3088 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3090 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3091 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3092 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3093 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3094 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3096 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3098 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3099 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3101 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3102 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3104 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3110 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3111 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3112 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3113 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3115 r = buf.Construct(imageLength);
3116 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3118 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3119 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3123 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3124 // webkit support types such as ico and vp8 additionally
3125 if (strcmp(pExtension, "gif") == 0)
3127 format = IMG_FORMAT_GIF;
3129 else if (strcmp(pExtension, "jpg") == 0)
3131 format = IMG_FORMAT_JPG;
3133 else if (strcmp(pExtension, "png") == 0)
3135 format = IMG_FORMAT_PNG;
3137 else if (strcmp(pExtension, "bmp") == 0)
3139 format = IMG_FORMAT_BMP;
3143 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3147 r = image.Construct();
3148 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3150 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3151 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3156 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3157 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3159 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3160 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3162 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3163 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3166 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3168 ewk_hit_test_free(pEwkHitTest);
3170 return pHitElementResult.release();
3173 ewk_hit_test_free(pEwkHitTest);
3180 _WebImpl::IsLoading(void) const
3182 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3184 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3196 _WebImpl::GetTextFromBlock(void) const
3198 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3203 _WebImpl::IsPrivateBrowsingEnabled(void) const
3205 if (__pWebCore->GetWebNativeNode() == null)
3207 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3210 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3211 SysAssertf(pSettings, "Failed to get webkit instance.");
3213 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3218 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3220 if (__pWebCore->GetWebNativeNode() == null)
3222 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3226 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3227 SysAssertf(pSettings, "Failed to get webkit instance.");
3229 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3234 _WebImpl::ClearHistory(void)
3236 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3241 _WebImpl::ClearCache(void)
3243 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3244 SysAssertf(pContext, "Failed to get webkit instance.");
3246 ewk_context_cache_clear(pContext);
3251 _WebImpl::ClearCookie(void)
3253 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3254 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3255 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3257 ewk_cookie_manager_cookies_clear(pCookieManager);
3262 _WebImpl::ClearFormData(void)
3264 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3265 SysAssertf(pContext, "Failed to get webkit instance.");
3267 ewk_context_form_candidate_data_clear(pContext);
3272 _WebImpl::ClearLoginFormData(void)
3274 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3275 SysAssertf(pContext, "Failed to get webkit instance.");
3277 ewk_context_form_password_data_clear(pContext);
3282 _WebImpl::IsCookieEnabled(void) const
3284 if (__pWebCore->GetWebNativeNode() == null)
3286 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3289 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3290 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3291 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3293 _WebPresenter presenter;
3294 presenter.InitAsyncProcess();
3296 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3298 bool result = false;
3299 presenter.WaitAsyncProcess(result);
3306 _WebImpl::SetCookieEnabled(bool enable)
3308 if (__pWebCore->GetWebNativeNode() == null)
3310 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3315 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3316 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3317 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3321 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3325 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3326 ewk_cookie_manager_cookies_clear(pCookieManager);
3332 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3334 result r = E_SUCCESS;
3336 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3337 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3340 String fileExtension = File::GetFileExtension(filePath);
3341 int pathLength = filePath.GetLength();
3344 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3346 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3347 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3348 r = filePath.SubString(0, index + 1, dirPath);
3349 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3351 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3352 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3356 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3358 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3362 Evas_Coord contentsWidth;
3363 Evas_Coord contentsHeight;
3365 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3366 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3374 _WebImpl::IsMimeSupported(const String& mime) const
3376 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3377 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3379 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3384 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3386 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3391 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3393 __pUserUiListener = pUiEventListener;
3398 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3400 __pUserUiListenerF = pUiEventListener;
3405 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3407 __pUserKeypadEventListener = pKeypadEventListener;
3412 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3414 if (__pWebDownloadHandler.get() == null)
3416 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3417 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3420 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3421 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3426 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3428 __pTextSearchListener = pTextSearchListener;
3433 _WebImpl::SetScrollEnabled(bool enable)
3435 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3440 _WebImpl::IsScrollEnabled(void) const
3442 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3447 _WebImpl::InitJsBridgeList(void)
3449 result r = E_SUCCESS;
3451 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3452 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3454 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3455 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3457 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3458 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3460 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3461 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3463 __pJsBridgeList = std::move(pJsBridgeList);
3470 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3472 result r = E_SUCCESS;
3474 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3475 String key(pJsBridge->GetName());
3477 r = __pJsBridgeList->Add(key, pJsBridge);
3478 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3485 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3487 result r = E_SUCCESS;
3489 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3490 String key(pJsBridge->GetName());
3492 r = __pJsBridgeList->Remove(key);
3493 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3500 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3502 result r = E_SUCCESS;
3504 IJsonValue* pJsonValue = null;
3505 IJavaScriptBridge* pJsBridge = null;
3507 String key(L"name");
3509 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3510 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));
3512 r = pJsonObject->GetValue(&key, pJsonValue);
3513 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3515 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3516 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3518 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3519 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3526 _WebImpl::GetLoadingListener(void) const
3528 return __pUserLoadingListener;
3532 IWebUiEventListener*
3533 _WebImpl::GetUiEventListener(void) const
3535 return __pUserUiListener;
3539 IWebUiEventListenerF*
3540 _WebImpl::GetUiEventListenerF(void) const
3542 return __pUserUiListenerF;
3546 IWebKeypadEventListener*
3547 _WebImpl::GetWebKeypadEventListener(void) const
3549 return __pUserKeypadEventListener;
3553 ITextSearchListener*
3554 _WebImpl::GetTextSearchListener(void) const
3556 return __pTextSearchListener;
3561 _WebImpl::SetEventListenerCallback(void) const
3563 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3566 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3567 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3569 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3570 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3572 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3573 SysAssertf(pSmartData, "Failed to request");
3575 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3576 SysAssertf(pSmart, "Failed to request");
3578 pSmart->popup_menu_show = OnSelectBoxRequested;
3579 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3580 pSmart->popup_menu_hide = OnSelectBoxClosed;
3581 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3583 pSmart->input_picker_show = OnDatePickerProviderRequested;
3584 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3585 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3587 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3588 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3589 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3590 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3592 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3594 // add loading event callbacks for ILoadingListener
3595 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3596 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3598 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3599 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3600 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3601 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3602 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3603 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3604 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3605 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3606 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3608 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3610 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3612 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3613 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3614 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3616 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3617 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3619 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3621 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3622 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3623 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3625 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3627 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3628 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3629 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3631 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3632 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3633 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3635 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3636 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3637 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3639 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3640 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3641 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3642 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3644 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3645 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3647 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3648 evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this);
3650 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3651 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3652 SysAssertf(pContext, "Failed to get webkit instance.");
3653 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3654 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3656 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3657 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3658 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3659 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3661 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3667 _WebImpl::RemoveEventListenerCallback(void) const
3669 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3672 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3673 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3675 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3676 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3678 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3679 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3681 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3682 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3683 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3684 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3685 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3686 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3687 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3688 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3690 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3692 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3694 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3695 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3696 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3698 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3699 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3701 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3703 ewk_view_javascript_alert_callback_set(null, null, null);
3704 ewk_view_javascript_prompt_callback_set(null, null, null);
3705 ewk_view_javascript_confirm_callback_set(null, null, null);
3707 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3709 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3710 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3711 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3713 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3714 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3715 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3716 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3717 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3718 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3720 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3721 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3722 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3724 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3726 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3727 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3729 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3730 evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation);
3732 ewk_view_open_panel_callback_set(null, null, null);
3733 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3734 SysAssertf(pContext, "Failed to get webkit instance.");
3735 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3737 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3738 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3739 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3740 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3742 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3748 _WebImpl::ClearCertificateDb(void)
3750 result r = E_SUCCESS;
3752 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3753 String table(CERTIFICATE_TABLE_NAME);
3756 r = db.Construct(certificatePath, "r+", null);
3757 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3759 db.BeginTransaction();
3761 r = db.ExecuteSql(L"Delete From " + table, true);
3762 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3764 db.CommitTransaction();
3769 db.RollbackTransaction();
3774 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3776 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3781 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3783 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3785 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3786 SysAssertf(pSmartData, "Failed to request");
3788 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3790 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3793 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3795 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3796 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3798 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3800 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3802 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3806 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3807 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3810 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3815 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3822 _WebImpl::ReleaseBlock(void)
3824 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3829 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3831 FloatPoint tempStartPoint;
3832 FloatPoint tempEndPoint;
3834 GetBlockRange(tempStartPoint, tempEndPoint);
3836 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3837 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3842 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3844 Eina_Rectangle leftHandle;
3845 Eina_Rectangle rightHandle;
3847 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3849 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3850 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3851 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3852 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3854 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3856 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3857 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3863 _WebImpl::GetFaviconN(void) const
3865 result r = E_SUCCESS;
3867 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3869 Evas* pEvas = evas_object_evas_get(pView);
3870 Ewk_Context* pContext = ewk_view_context_get(pView);
3871 SysAssertf(pEvas && pContext, "Failed to request");
3873 const char* pUrl = ewk_view_url_get(pView);
3875 Tizen::Graphics::BufferInfo bufferInfo;
3876 Tizen::Base::ByteBuffer byteBuffer;
3878 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3879 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3881 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3887 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3888 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3890 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3892 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3893 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3895 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3896 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3898 return pBitmapImage.release();
3904 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3906 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3911 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3913 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3918 _WebImpl::GetScrollPosition(void) const
3922 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3929 _WebImpl::GetPageSize(void) const
3931 Evas_Coord width = 0;
3932 Evas_Coord height = 0;
3934 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3936 Dimension size(static_cast< int >(width), static_cast< int >(height));
3943 _WebImpl::SetLoadingErrorOccurred(bool arg)
3945 __isLoadingErrorOccurred = arg;
3950 _WebImpl::IsLoadingErrorOccurred(void) const
3952 return __isLoadingErrorOccurred;
3957 _WebImpl::SetRedirectRequested(bool arg)
3959 __isRedirectRequested = arg;
3964 _WebImpl::IsRedirectRequested(void) const
3966 return __isRedirectRequested;
3971 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3978 _WebImpl::GetPolicyDecision(void) const
3985 _WebImpl::SetCertificateRequested(bool arg)
3987 __isCertificateRequested = arg;
3992 _WebImpl::IsCertificateRequested(void) const
3994 return __isCertificateRequested;
3999 _WebImpl::SetCertificateConfirmed(bool arg)
4001 __isCertificateConfirmed = arg;
4006 _WebImpl::IsCertificateConfirmed(void) const
4008 return __isCertificateConfirmed;
4013 _WebImpl::SetOrientationChanged(bool arg)
4015 __isOrientationChanged = arg;
4020 _WebImpl::IsOrientationChanged(void) const
4022 return __isOrientationChanged;
4027 _WebImpl::LaunchAppControl(const IEventArg& arg)
4029 result r = E_SUCCESS;
4031 IEventArg* pArg = const_cast< IEventArg* >(&arg);
4032 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
4033 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
4035 String operationId(L"");
4036 String uriPattern(pWebEventArg->GetEventMessage());
4037 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
4039 switch (pWebEventArg->GetEventType())
4041 case WEB_EVENT_REQUEST_RTSP:
4045 int uriLength = uriPattern.GetLength();
4048 operationId = L"http://tizen.org/appcontrol/operation/view";
4050 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
4051 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4053 r = uriPattern.SubString(index + 1, ext);
4054 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4056 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
4057 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4059 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
4060 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4064 case WEB_EVENT_REQUEST_TEL:
4066 operationId = L"http://tizen.org/appcontrol/operation/dial";
4069 case WEB_EVENT_REQUEST_EMAIL:
4071 case WEB_EVENT_REQUEST_SMS:
4073 case WEB_EVENT_REQUEST_MMS:
4075 operationId = L"http://tizen.org/appcontrol/operation/compose";
4078 case WEB_EVENT_REQUEST_UNKNOWN:
4080 operationId = L"http://tizen.org/appcontrol/operation/view";
4088 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
4089 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4096 _WebImpl::SetFullScreenKeypad(void)
4098 result r = E_SUCCESS;
4100 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4101 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4103 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4104 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4106 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4107 pKeypad->SetText(text);
4109 r = pKeypad->SetShowState(true);
4110 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4112 r = pKeypad->Show();
4113 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4115 pKeypad->AddTextEventListener(*this);
4117 __pKeypad = std::move(pKeypad);
4124 _WebImpl::RemoveFullScreenKeypad(void)
4126 __pKeypad->RemoveTextEventListener(*this);
4133 _WebImpl::IsFooterVisible(void) const
4135 return __isFooterVisible;
4140 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4142 __isFooterVisible = isFooterVisible;
4147 _WebImpl::IsKeypadVisible(void) const
4149 return __isKeypadVisible;
4154 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4156 __isKeypadVisible = isKeypadVisible;
4161 _WebImpl::IsKeypadOpened(void) const
4163 return __isKeypadOpened;
4167 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4169 __isKeypadOpened = isKeypadOpened;
4174 _WebImpl::GetPreviousKeypadBounds(void) const
4176 return __keypadBounds;
4181 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4183 __keypadBounds = bounds;
4188 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4190 RemoveFullScreenKeypad();
4195 _WebImpl::OnTextValueChanged(const Control& source)
4197 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4199 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4201 RemoveFullScreenKeypad();
4206 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4208 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4209 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4211 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4212 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4214 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4215 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4217 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4224 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4226 result r = E_SUCCESS;
4228 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4229 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4231 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4233 ILoadingListener* pLoadingListner = GetLoadingListener();
4234 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4236 switch (pEventArg->GetEventType())
4238 case WEB_EVENT_LOADINGLISTENER_STARTED:
4240 pLoadingListner->OnLoadingStarted();
4244 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4246 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4247 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4249 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4253 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4255 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4256 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4258 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4262 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4264 pLoadingListner->OnLoadingCanceled();
4268 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4270 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4271 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4273 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4274 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4276 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4278 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4282 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4284 pLoadingListner->OnLoadingCompleted();
4288 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4290 pLoadingListner->OnHttpAuthenticationCanceled();
4294 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4296 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4297 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4301 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4317 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4319 result r = E_SUCCESS;
4321 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4322 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4324 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4326 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4327 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4329 switch (pEventArg->GetEventType())
4331 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4333 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4334 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4336 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4340 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4342 pWebDownloadListener->OnWebDataDownloadCompleted();
4346 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4348 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4349 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4351 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4353 pWebDownloadListener->OnWebDownloadFailed(errorType);
4368 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4370 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4371 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4373 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4375 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4377 switch (pEventArg->GetEventType())
4379 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4381 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4383 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4384 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4386 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4387 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4389 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4393 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4395 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4397 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4401 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4403 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4405 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4409 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4411 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4413 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4414 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4416 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4431 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4433 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4434 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4436 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4438 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4440 switch (pEventArg->GetEventType())
4442 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4444 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4446 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4447 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4449 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4450 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4452 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4456 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4458 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4460 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4464 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4466 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4468 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4472 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4474 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4476 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4477 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4479 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4494 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4496 result r = E_SUCCESS;
4498 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4499 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4501 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4503 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4504 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4506 switch (pEventArg->GetEventType())
4508 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4510 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4511 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4513 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4514 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4516 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4531 _WebImpl::VibrationRequested(uint64_t duration)
4533 result r = E_SUCCESS;
4535 __pVibrator.reset();
4537 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4538 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4540 r = pVibrator->Construct();
4541 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4543 __pVibrator = std::move(pVibrator);
4545 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4547 r = __pVibrator->Start(&pattern, 1, 1);
4548 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4555 _WebImpl::VibrationCanceled(void)
4557 __pVibrator.reset();
4562 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4564 result r = E_SUCCESS;
4566 String host(ewk_auth_challenge_url_get(pChallenge));
4567 String realm(ewk_auth_challenge_realm_get(pChallenge));
4569 __pAuthChallenge.reset();
4571 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4572 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4574 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4575 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4577 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4578 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4580 __pAuthChallenge = std::move(pAuthChallenge);
4582 ewk_auth_challenge_suspend(pChallenge);
4583 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4585 __pAuthChallenge.release();
4589 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4590 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4598 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4600 result r = E_SUCCESS;
4602 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4603 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4605 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4606 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4608 __pAuthPopup = std::move(pAuthPopup);
4610 int modalResult = 0;
4612 __pAuthPopup->SetOwner(&GetPublic());
4614 r = __pAuthPopup->ShowAndWait(modalResult);
4615 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4618 __pAuthPopup.reset();
4625 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4627 result r = E_SUCCESS;
4629 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4630 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4632 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4633 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4635 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4637 int modalResult = 0;
4639 __pCertConfirmPopup->SetOwner(&GetPublic());
4641 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4642 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4644 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4646 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4650 __pCertConfirmPopup.reset();
4656 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4658 result r = E_SUCCESS;
4660 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4661 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4663 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
4664 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4666 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4668 int modalResult = 0;
4670 __pUserConfirmPopup->SetOwner(&GetPublic());
4672 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4673 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4676 __pUserConfirmPopup.reset();
4682 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4684 result r = E_SUCCESS;
4686 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4687 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4689 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
4690 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4692 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4694 __pUserConfirmPopup->SetOwner(&GetPublic());
4696 r = __pUserConfirmPopup->ShowPopup();
4697 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4699 __pUserConfirmPopup.release();
4704 __pUserConfirmPopup.reset();
4711 _WebImpl::GetParentFormCore(_Control* pControlCore)
4714 _Form* pFormCore = null;
4716 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4717 if (!pParentControlCore)
4722 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4728 return GetParentFormCore(pParentControlCore);
4733 _WebImpl::OnFocusGained(const _ControlImpl& source)
4740 _WebImpl::OnFocusLost(const _ControlImpl& source)
4742 if(IsKeypadVisible() == true)
4744 SetKeypadOpened(true);
4746 SetKeypadVisibleState(false);
4749 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4756 _WebImpl::HasValidNativeNode(void) const
4758 if (__pWebCore && __pWebCore->GetWebNativeNode())
4768 _WebImpl::OnPreAttachedToMainTree(void)
4770 result r = E_SUCCESS;
4772 r = __pWebCore->InitializeWebNativeNode();
4773 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4775 r = InitializeSetting();
4776 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4778 r = _ContainerImpl::OnPreAttachedToMainTree();
4779 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4786 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4788 _ContainerImpl::OnChangeLayout(orientation);
4790 if (__pColorPicker.get())
4792 __pColorPicker->ChangeLayout(orientation);
4795 HideFormDataWindow();
4797 __isOrientationChanged = true;
4802 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4804 if (IsVisible() == true)
4806 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4810 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4816 _WebImpl::GetDownloadHandler(void) const
4818 return __pWebDownloadHandler.get();
4823 _WebImpl::HideColorPicker(void)
4825 __pColorPicker.reset();
4832 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4834 result r = E_SUCCESS;
4836 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4837 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4839 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4841 r = pColorHadler->Construct(colorVal, this);
4842 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4844 __pColorPicker = std::move(pColorHadler);
4846 r = __pColorPicker->ShowPopup();
4847 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4849 color = __pColorPicker->GetColor();
4854 __pColorPicker.reset();
4861 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4863 result r = E_SUCCESS;
4865 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4866 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4868 r = pInputPicker->Construct(String(inputValue), inputType, this);
4869 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4871 __pDatePicker = std::move(pInputPicker);
4873 r = __pDatePicker->ShowPopup();
4874 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4876 dateStr = __pDatePicker->GetDate();
4879 __pDatePicker.reset();
4886 _WebImpl::GetInstance(Web* pWeb)
4888 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4893 _WebImpl::GetInstance(const Web* pWeb)
4895 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4900 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4902 int checkReturn = 0;
4904 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4907 if( checkmime == true)
4909 table = CUSTOM_CONTENT_TABLE_NAME;
4913 table = CUSTOM_PROTOCOL_TABLE_NAME;
4916 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4917 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4918 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4920 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4922 result r = db.Construct(handlerPath, "r+", null);
4923 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4925 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"'"));
4926 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4930 r = pEnum->MoveNext();
4931 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4932 r = pEnum->GetIntAt(0, checkReturn);
4933 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4945 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4949 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4952 if( checkmime == true)
4954 table = CUSTOM_CONTENT_TABLE_NAME;
4958 table = CUSTOM_PROTOCOL_TABLE_NAME;
4961 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4962 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4963 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4965 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4967 result r = db.Construct(handlerPath, "r+", null);
4968 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4970 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"'"));
4971 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4975 r = pEnum->MoveNext();
4976 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4977 r = pEnum->GetIntAt(0, checkId);
4978 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4980 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
4981 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4983 r = pDeleteStmt->BindInt(0, checkId);
4984 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4986 db.BeginTransaction();
4988 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
4990 db.CommitTransaction();
4997 const Tizen::Base::String
4998 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5000 if (originUri == L"" || currentUri == L"")
5005 result r = E_SUCCESS;
5008 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5009 String originReplace(originUri);
5010 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5014 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5015 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5017 r = currentUri.SubString(0, found + 1, baseUri);
5018 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5020 r = db.Construct(handlerPath, "r+", null);
5021 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5023 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5024 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5028 while (pEnum->MoveNext() == E_SUCCESS)
5033 String originScheme;
5035 r = pEnum->GetStringAt(0, protocol);
5036 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5038 r = pEnum->GetStringAt(1, queryUrl);
5039 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5041 r = pEnum->GetIntAt(2, allow);
5042 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5049 String protocolScheme(protocol + L":");
5051 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5052 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5054 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5056 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5058 r = originReplace.Replace(originScheme, "");
5059 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5061 queryUrl.Replace("%s", originReplace, 0);
5062 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5074 const Tizen::Base::String
5075 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5077 if (originUri == L"" || currentUri == L"" || mime == L"")
5082 result r = E_SUCCESS;
5085 String originUrlStr = originUri;
5086 const String replaceStr = L"%s";
5088 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5089 String table(CUSTOM_CONTENT_TABLE_NAME);
5093 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5094 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5096 r = currentUri.SubString(0, found + 1, baseUri);
5097 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5099 r = db.Construct(handlerPath, "r+", null);
5100 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5102 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5106 r = pEnum->MoveNext();
5107 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5108 r = pEnum->GetIntAt(0, allow);
5109 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5110 r = pEnum->GetStringAt(1, contentUrl);
5111 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5119 if (contentUrl != L"")
5121 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5122 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5134 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5136 __pFormDataList = pFormDataList;
5141 _WebImpl::IsFormDataWindowVisible(void) const
5143 return __isFormDataVisible;
5148 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5150 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5152 if (__isFormDataVisible)
5154 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5155 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5159 __pFormDataWindow.reset();
5161 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5162 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5164 result r = pFormDataWindow->Construct(rect, this, pWebView);
5165 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5167 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5168 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5170 r = pFormDataWindow->LaunchFormDataWindow();
5171 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5173 __pFormDataWindow = std::move(pFormDataWindow);
5174 __isFormDataVisible = true;
5182 _WebImpl::HideFormDataWindow(bool delWindow)
5186 __pFormDataWindow.reset();
5189 __isFormDataVisible = false;
5193 }}} // Tizen::Web::Controls