2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_WebImpl.cpp
20 * @brief The file contains the definition of _WebImpl class.
22 * The file contains the definition of _WebImpl class.
24 #include <Ecore_IMF_Evas.h>
25 #include <Ecore_Evas.h>
26 #include <elm_config.h>
29 #include <ewk_popup_menu_item.h>
30 #include <libsoup/soup-status.h>
32 #include <FAppAppControl.h>
33 #include <FAppIAppControlListener.h>
34 #include <FBaseColAllElementsDeleter.h>
35 #include <FBaseColHashMapT.h>
36 #include <FBaseRtMutex.h>
37 #include <FBaseRtMutexGuard.h>
38 #include <FBaseSysLog.h>
39 #include <FBaseUtilUri.h>
40 #include <FCntDownloadRequest.h>
41 #include <FGrpColor.h>
42 #include <FGrpPoint.h>
43 #include <FGrpRectangle.h>
44 #include <FIoDbEnumerator.h>
45 #include <FIoDbStatement.h>
47 #include <FMediaImage.h>
48 #include <FMediaImageTypes.h>
49 #include <FNetHttpHttpHeader.h>
50 #include <FSysVibrator.h>
51 #include <FUiControl.h>
52 #include <FUiCtrlKeypad.h>
53 #include <FWebCtrlHitElementResult.h>
54 #include <FWebCtrlITextSearchListener.h>
55 #include <FWebCtrlIWebDownloadListener.h>
56 #include <FWebCtrlIWebUiEventListener.h>
57 #include <FWebCtrlIWebUiEventListenerF.h>
58 #include <FWebCtrlIWebKeypadEventListener.h>
59 #include <FWebCtrlIJavaScriptBridge.h>
60 #include <FWebCtrlPageNavigationList.h>
61 #include <FWebCtrlAuthenticationChallenge.h>
62 #include <FWebCtrlWeb.h>
63 #include <FWebCtrlWebSetting.h>
64 #include <FWebHistoryItem.h>
65 #include <FWebJsonJsonObject.h>
66 #include <FWebJsonJsonParser.h>
67 #include <FWebJsonJsonString.h>
68 #include <FApp_AppControlImpl.h>
69 #include <FApp_AppControlManager.h>
70 #include <FApp_AppInfo.h>
71 #include <FApp_AppManagerImpl.h>
72 #include <FBase_StringConverter.h>
73 #include <FCnt_DownloadManagerImpl.h>
74 #include <FCnt_ContentManagerImpl.h>
75 #include <FGrp_CoordinateSystem.h>
76 #include <FGrp_Screen.h>
77 #include <FIo_DatabaseImpl.h>
78 #include <FIo_NormalFile.h>
79 #include <FSys_SystemResource.h>
80 #include <FSys_VibratorImpl.h>
81 #include <FUi_Control.h>
82 #include <FUi_CoordinateSystemUtils.h>
83 #include <FUi_EcoreEvasMgr.h>
84 #include <FUi_EcoreEvas.h>
85 #include <FUi_ResourceSizeInfo.h>
86 #include <FUi_Window.h>
87 #include <FUiAnim_EflNode.h>
88 #include <FUiAnim_VisualElement.h>
89 #include <FUiCtrl_FooterImpl.h>
90 #include <FUiCtrl_Form.h>
91 #include "FWeb_HistoryItemImpl.h"
92 #include "FWebCtrl_AppControlListener.h"
93 #include "FWebCtrl_AuthConfirmPopup.h"
94 #include "FWebCtrl_AuthenticationChallengeImpl.h"
95 #include "FWebCtrl_EflWebkit.h"
96 #include "FWebCtrl_FormDataWindow.h"
97 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
98 #include "FWebCtrl_HitElementResultImpl.h"
99 #include "FWebCtrl_InputPickerPopup.h"
100 #include "FWebCtrl_WebNotification.h"
101 #include "FWebCtrl_PageNavigationListImpl.h"
102 #include "FWebCtrl_PromptPopup.h"
103 #include "FWebCtrl_SelectBox.h"
104 #include "FWebCtrl_Utility.h"
105 #include "FWebCtrl_Web.h"
106 #include "FWebCtrl_WebDataHandler.h"
107 #include "FWebCtrl_WebEvent.h"
108 #include "FWebCtrl_WebEventArg.h"
109 #include "FWebCtrl_WebImpl.h"
110 #include "FWebCtrl_WebPresenter.h"
111 #include "FWebCtrl_WebSettingImpl.h"
114 using namespace Tizen::App;
115 using namespace Tizen::Base;
116 using namespace Tizen::Base::Collection;
117 using namespace Tizen::Base::Runtime;
118 using namespace Tizen::Base::Utility;
119 using namespace Tizen::Content;
120 using namespace Tizen::Graphics;
121 using namespace Tizen::Io;
122 using namespace Tizen::Media;
123 using namespace Tizen::Net::Http;
124 using namespace Tizen::System;
125 using namespace Tizen::Ui;
126 using namespace Tizen::Ui::Animations;
127 using namespace Tizen::Ui::Controls;
128 using namespace Tizen::Web::Json;
131 namespace Tizen { namespace Web { namespace Controls
135 static const char WEB_CTRL[] = "webcontrol";
136 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
139 static const float MIN_ZOOM_LEVEL = 0.3;
140 static const float MAX_ZOOM_LEVEL = 2;
143 static const int REDIRECTION_HEADER_GROUP = 300;
146 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
149 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
150 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
151 static const int DEFAULT_LIST_ITEM_COUNT = 4;
155 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
157 result r = E_SUCCESS;
159 String key(reinterpret_cast< const char* >(pKey));
160 String value(reinterpret_cast< char* >(pValue));
162 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
164 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
165 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
172 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
174 result r = E_SUCCESS;
176 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
177 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
178 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
180 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
182 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
183 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
185 pAttrValue.release();
192 FreeCharArray(void* pData)
194 delete[] reinterpret_cast<char*>(pData);
199 ConvertErrorCode(int error)
201 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
205 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
207 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
209 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
211 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
213 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
215 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
217 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
219 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
221 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
223 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
225 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
227 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
229 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
231 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
232 errorCode = WEB_NO_CONNECTION;
235 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
237 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
238 errorCode = WEB_BAD_URL;
241 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
242 errorCode = WEB_FILE_ACCESS_FAILED;
245 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
246 errorCode = WEB_REQUEST_TIMEOUT;
249 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
250 errorCode = WEB_MIME_NOT_SUPPORTED;
253 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
254 errorCode = WEB_OUT_OF_MEMORY;
257 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
258 errorCode = WEB_REQUEST_MAX_EXCEEDED;
261 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
263 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
265 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
267 case EWK_ERROR_NETWORK_STATUS_OK:
269 case EWK_ERROR_NETWORK_STATUS_CREATED:
271 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
273 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
275 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
277 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
279 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
281 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
283 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
285 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
287 case EWK_ERROR_NETWORK_STATUS_FOUND:
289 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
291 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
293 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
295 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
297 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
298 errorCode = WEB_HTTP_RESPONSE;
301 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
302 errorCode = WEB_INVALID_CERTIFICATE;
306 errorCode = WEB_ERROR_UNKNOWN;
315 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
317 result r = E_SUCCESS;
319 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
320 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
321 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
322 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
324 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
325 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
326 pErrorCode.release();
328 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
329 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
330 pErrorDescription.release();
332 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
333 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
341 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
343 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
345 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
346 String msg(pMessage);
348 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
349 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
353 ewk_view_javascript_alert_reply(pView);
359 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
361 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
363 result r = E_SUCCESS;
364 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
365 String msg(pMessage);
367 MessageBox messageBox;
368 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
369 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
373 messageBox.SetOwner(&pImpl->GetPublic());
375 r = messageBox.ShowAndWait(modalResult);
376 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
378 if (modalResult == MSGBOX_RESULT_OK)
380 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
384 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
392 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
394 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
396 result r = E_SUCCESS;
397 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
399 String msg(pMessage);
400 String defVal(pDefaultValue);
402 r = pImpl->ShowPromptPopup(msg, defVal);
403 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
408 ewk_view_javascript_prompt_reply(pView, null);
415 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
417 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
418 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
419 SysAssertf(pImpl && pPolicy, "Failed to request");
421 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
423 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
425 if (pImpl->IsCertificateRequested())
427 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
431 result r = E_SUCCESS;
433 std::unique_ptr<DbEnumerator> pEnum;
435 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
436 String table(CERTIFICATE_TABLE_NAME);
439 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
441 r = db.Construct(certificatePath, "r", null);
442 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
444 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
447 r = pEnum->MoveNext();
448 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
451 r = pEnum->GetIntAt(0, allow);
452 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
454 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
456 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
457 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
461 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
462 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
465 pImpl->SetCertificateRequested(true);
468 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
469 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
471 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
472 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
481 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
482 pImpl->SetCertificateConfirmed(false);
483 pImpl->SetCertificateRequested(true);
488 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
490 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
491 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
492 SysAssertf(pImpl && pChallenge, "Failed to request");
494 result r = E_SUCCESS;
496 r = pImpl->HttpAuthenticationRequested(pChallenge);
497 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
501 ewk_auth_challenge_credential_cancel(pChallenge);
502 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
507 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
509 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
510 SysAssertf(pImpl , "Failed to request");
512 if (pImpl->GetLoadingListener())
514 result r = E_SUCCESS;
516 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
517 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
519 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
520 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
526 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
528 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
529 SysAssertf(pImpl , "Failed to request");
531 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
533 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
534 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
536 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
537 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
544 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
546 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
547 SysAssertf(pImpl , "Failed to request");
549 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
551 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
552 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
554 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
555 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
562 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
564 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
565 SysAssertf(pImpl , "Failed to request");
567 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
569 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
570 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
572 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
573 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
579 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
581 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
582 SysAssertf(pImpl , "Failed to request");
584 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
586 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
587 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
589 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
590 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
597 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
599 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
600 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
601 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
603 if (pImpl->GetSetting().IsGeolocationEnabled())
605 result r = E_SUCCESS;
607 std::unique_ptr<DbEnumerator> pEnum;
609 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
610 String table(GEOLOCATION_TABLE_NAME);
613 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
614 String origin = _Utility::CreateOrigin(pSecurityOrigin);
616 r = db.Construct(geolocationPath, "r", null);
617 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
619 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
622 r = pEnum->MoveNext();
623 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
626 r = pEnum->GetIntAt(0, permission);
627 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
629 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
631 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
635 ewk_geolocation_permission_request_suspend(pPermissionRequest);
637 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
638 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
645 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
650 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
652 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
653 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
654 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
656 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
657 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
661 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
666 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
668 result r = E_SUCCESS;
669 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
671 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
672 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
674 ewk_notification_permission_request_suspend(pPermissionRequest);
676 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
677 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
681 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
686 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
688 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
689 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
690 SysAssertf(pImpl && pNotification, "Failed to request");
692 result r = E_SUCCESS;
693 Ewk_Context* pContext = ewk_view_context_get(pView);
694 SysAssertf(pContext, "Failed to get webkit instance.");
695 uint64_t notificationId = ewk_notification_id_get(pNotification);
697 //ewk_notification_security_origin_get(pNotification)
699 const char* text = ewk_notification_body_get(pNotification);
700 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
702 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
703 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
705 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
706 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
708 pNotificationWindow->SetText(String(text));
709 pNotificationWindow->LaunchNotification();
710 pNotificationWindow.release();
712 ewk_notification_showed(pContext, notificationId);
717 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
719 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
720 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
721 SysAssertf(pImpl && pNotificationID, "Failed to request");
723 //ToDo : Where is ewk API for cancel operation?
728 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
730 result r = E_SUCCESS;
731 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
732 SysAssertf(pImpl, "Failed to request");
734 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
735 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
740 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
742 int checkHandler = 0;
743 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
744 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
745 SysAssertf(pImpl && pHandlerData, "Failed to request");
747 checkHandler = pImpl->SearchHandler(pHandlerData, false);
748 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
749 switch (checkHandler)
754 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
757 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
760 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
768 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
770 result r = E_SUCCESS;
771 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
772 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
773 SysAssertf(pImpl && pHandlerData, "Failed to request");
775 r = pImpl->UnregistrationHandler(pHandlerData, false);
776 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
781 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
783 result r = E_SUCCESS;
784 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
785 SysAssertf(pImpl, "Failed to request");
787 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
788 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
793 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
795 int checkHandler = 0;
796 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
797 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
798 SysAssertf(pImpl && pHandlerData, "Failed to request");
800 checkHandler = pImpl->SearchHandler(pHandlerData, true);
801 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
803 switch (checkHandler)
808 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
811 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
814 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
823 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
825 result r = E_SUCCESS;
826 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
827 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
828 SysAssertf(pImpl && pHandlerData, "Failed to request");
830 r = pImpl->UnregistrationHandler(pHandlerData, true);
831 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
836 OnVibrationRequested(uint64_t duration, void* pUserData)
838 result r = E_SUCCESS;
840 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
841 SysAssertf(pImpl, "Failed to request");
843 r = pImpl->VibrationRequested(duration);
844 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
849 OnVibrationCanceled(void* pUserData)
851 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
852 SysAssertf(pImpl, "Failed to request");
854 pImpl->VibrationCanceled();
859 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
861 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
862 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
863 SysAssertf(pImpl && pPolicy, "Failed to request");
865 String url(ewk_policy_decision_url_get(pPolicy));
866 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
868 if (url == L"about:blank")
870 ewk_policy_decision_use(pPolicy);
874 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
875 && !pImpl->IsRedirectRequested())
877 pImpl->SetCertificateRequested(false);
879 if (pImpl->GetTextSearchListener())
881 pImpl->DisableAsyncSearch();
884 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
885 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
887 switch (ewkNavigationType)
889 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
890 navigationType = WEB_NAVIGATION_LINK_CLICKED;
892 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
893 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
895 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
896 navigationType = WEB_NAVIGATION_BACKFORWARD;
898 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
899 navigationType = WEB_NAVIGATION_RELOAD;
901 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
902 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
904 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
905 navigationType = WEB_NAVIGATION_OTHER;
911 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
913 ewk_policy_decision_ignore(pPolicy);
919 String currentUrl(pImpl->GetUrl());
920 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
921 if (redirectUrl != L"")
923 pImpl->LoadUrl(redirectUrl);
924 ewk_policy_decision_ignore(pPolicy);
932 String uriScheme(uri.GetScheme());
933 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
935 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
937 ewk_policy_decision_ignore(pPolicy);
939 if (uriScheme == L"")
944 result r = E_SUCCESS;
946 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
948 if (uriScheme == L"rtsp")
950 eventType = WEB_EVENT_REQUEST_RTSP;
952 else if (uriScheme == L"mailto")
954 eventType = WEB_EVENT_REQUEST_EMAIL;
956 else if (uriScheme == L"tel")
958 eventType = WEB_EVENT_REQUEST_TEL;
960 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
962 eventType = WEB_EVENT_REQUEST_SMS;
964 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
966 eventType = WEB_EVENT_REQUEST_MMS;
969 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
970 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
972 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
973 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
979 ewk_policy_decision_use(pPolicy);
984 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
986 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
987 SysAssertf(pImpl, "Failed to request");
989 if (pImpl->GetLoadingListener())
991 result r = E_SUCCESS;
993 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
994 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
996 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
997 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1004 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1006 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1007 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1008 SysAssertf(pImpl, "Failed to request");
1010 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1012 if (pImpl->GetLoadingListener())
1014 result r = E_SUCCESS;
1016 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1017 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1018 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1020 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1021 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1022 pPageTitle.release();
1024 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1025 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1026 pEventArg.release();
1032 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1034 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1035 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1036 SysAssertf(pImpl, "Failed to request");
1038 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1040 if (pImpl->GetLoadingListener())
1042 result r = E_SUCCESS;
1044 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1045 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1046 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1048 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1049 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1050 pProgressPercentage.release();
1052 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1053 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1054 pEventArg.release();
1060 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1062 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1063 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1064 SysAssertf(pImpl && pPolicy, "Failed to request");
1066 result r = E_SUCCESS;
1068 _SystemResource* pSysResource = _SystemResource::GetInstance();
1069 SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
1071 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1072 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1073 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1074 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1076 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1078 String url(ewk_policy_decision_url_get(pPolicy));
1081 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1083 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1085 DecisionPolicy policy;
1086 HttpHeader httpHeader;
1088 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1090 pImpl->SetRedirectRequested(true);
1094 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1095 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1097 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1098 pImpl->SetPolicyDecision(policy);
1101 switch (pImpl->GetPolicyDecision())
1103 case WEB_DECISION_CONTINUE:
1105 String currentUrl(pImpl->GetUrl());
1106 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1107 if (redirectUrl != L"")
1109 pImpl->LoadUrl(redirectUrl);
1110 ewk_policy_decision_ignore(pPolicy);
1115 if (pImpl->IsMimeSupported(mime) || mime == L"")
1122 SysLog(NID_WEB_CTRL, "Launch native app to handle the mime");
1124 ewk_policy_decision_ignore(pPolicy);
1126 AppControl* pAppControl = null;
1127 _SelectBox selectBox;
1129 int selectedIndex = 0;
1131 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
1135 appCount = pList->GetCount();
1138 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
1139 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1141 selectBox.AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1142 for (int i = 0; i < appCount; i++)
1144 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
1145 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1147 String text = pAppControl->GetAppName();
1148 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
1150 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1152 r = selectBox.ShowAndWait(selectedIndex);
1153 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1155 if (selectedIndex == 0) //download
1157 RequestId reqId = 0;
1158 DownloadRequest request(pUrl);
1160 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1161 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1163 pManagerImpl->SetDownloadListener(pImpl);
1164 r = pManagerImpl->Start(request, reqId);
1165 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1167 else if (selectedIndex != -1) // -1 for cancel
1169 String path("path");
1170 String pathVal(pUrl);
1173 r = dataList.Construct();
1174 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1176 r = dataList.Add(path, pathVal);
1177 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1179 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
1180 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1182 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
1183 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1185 r = pAcImpl->Start(null, null, &dataList, null);
1186 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1193 case WEB_DECISION_DOWNLOAD:
1195 ewk_policy_decision_ignore(pPolicy);
1197 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1198 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1200 Ewk_Context* pContext = ewk_view_context_get(pView);
1201 SysAssertf(pContext, "Failed to get webkit instance.");
1203 pDownloadHandler->StartDownload(pUrl);
1207 case WEB_DECISION_IGNORE:
1209 ewk_policy_decision_ignore(pPolicy);
1219 ewk_policy_decision_use(pPolicy);
1224 ewk_policy_decision_ignore(pPolicy);
1229 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1231 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1232 SysAssertf(pImpl, "Failed to request");
1234 if (pImpl->IsRedirectRequested())
1236 pImpl->SetRedirectRequested(false);
1239 if (pImpl->IsLoadingErrorOccurred())
1241 pImpl->SetLoadingErrorOccurred(false);
1242 evas_object_smart_callback_call(pView, "load,finished", NULL);
1248 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1250 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1251 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1252 SysAssertf(pImpl && pErrorData, "Failed to request");
1254 int code = ewk_error_code_get(pErrorData);
1255 const char* pDescription = ewk_error_description_get(pErrorData);
1257 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1261 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1262 pImpl->SetLoadingErrorOccurred(true);
1265 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1266 evas_object_smart_callback_call(pView, "load,finished", NULL);
1269 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1270 pImpl->SetLoadingErrorOccurred(true);
1271 evas_object_smart_callback_call(pView, "load,stop", NULL);
1275 pImpl->SetLoadingErrorOccurred(true);
1276 if (pImpl->GetLoadingListener())
1278 result r = E_SUCCESS;
1280 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1281 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1289 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1291 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1292 SysAssertf(pImpl, "Failed to request");
1294 if (pImpl->GetLoadingListener())
1296 result r = E_SUCCESS;
1298 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1299 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1301 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1302 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1303 pEventArg.release();
1310 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1312 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1313 SysAssertf(pImpl, "Failed to request");
1315 if (pImpl->GetLoadingListener())
1317 result r = E_SUCCESS;
1319 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1320 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1322 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1323 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1324 pEventArg.release();
1331 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1333 evas_object_focus_set(pView, EINA_FALSE);
1338 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1340 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1341 SysAssertf(pImpl, "Failed to request");
1343 if (pImpl->GetLoadingListener())
1345 result r = E_SUCCESS;
1347 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1348 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1350 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1351 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1352 pEventArg.release();
1359 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1361 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1362 SysAssertf(pUrl && pImpl != null, "Failed to request");
1364 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1369 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1371 result r = E_SUCCESS;
1373 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1374 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1376 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1377 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1378 pEventArg.release();
1385 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1387 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1388 SysAssertf(pImpl, "Failed to request");
1390 if (pImpl->GetUiEventListener())
1392 result r = E_SUCCESS;
1394 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1395 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1397 if (pImpl->GetUiEventListenerF())
1399 result r = E_SUCCESS;
1401 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1402 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1408 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1410 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1411 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1412 SysAssertf(pParentImpl && pChildView, "Failed to request");
1414 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1415 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1416 if (pUserUiListener)
1418 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1421 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1422 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1424 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1425 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1428 if (pUserUiListenerF)
1430 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1433 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1434 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1436 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1437 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1444 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1446 result r = E_SUCCESS;
1448 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1449 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1451 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1452 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1453 pEventArg.release();
1460 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1462 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1463 SysAssertf(pChildImpl, "Failed to request");
1465 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1466 if (pParentImpl == null)
1471 if (pParentImpl->GetUiEventListener())
1473 result r = E_SUCCESS;
1475 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1476 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1478 if (pParentImpl->GetUiEventListenerF())
1480 result r = E_SUCCESS;
1482 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1483 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1489 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1491 result r = E_SUCCESS;
1493 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1494 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1495 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1497 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1498 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1499 pPreventTrigger.release();
1501 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1502 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1503 pEventArg.release();
1510 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1512 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1513 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1514 SysAssertf(pImpl && pTrigger, "Failed to request");
1516 if (pImpl->GetUiEventListener())
1518 result r = E_SUCCESS;
1520 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1521 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1523 if (pImpl->GetUiEventListenerF())
1525 result r = E_SUCCESS;
1527 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1528 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1534 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1536 result r = E_SUCCESS;
1538 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1539 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1540 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1542 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1544 if ((endPoint->x != 0) && (endPoint->y != 0))
1546 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1547 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1549 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1550 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1551 startPoint.release();
1553 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1554 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1557 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1558 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1559 pEventArg.release();
1567 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1569 result r = E_SUCCESS;
1571 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1572 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1574 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1576 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1578 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1580 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1581 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1583 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1584 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1585 startPoint.release();
1587 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1588 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1591 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1592 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1593 pEventArg.release();
1601 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1603 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1604 SysAssertf(pImpl, "Failed to request");
1606 if (pImpl->GetUiEventListener())
1608 result r = E_SUCCESS;
1610 r = FireWebPageBlockSelectedEvent(pImpl);
1611 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1613 if (pImpl->GetUiEventListenerF())
1615 result r = E_SUCCESS;
1617 r = FireWebPageBlockSelectedEventF(pImpl);
1618 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1624 OnWebPageBlockSelectedByOrientation(void* pUserData, Evas_Object* pView, void* pEventInfo)
1626 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1627 SysAssertf(pImpl, "Failed to request");
1629 if (!pImpl->IsOrientationChanged())
1634 pImpl->SetOrientationChanged(false);
1636 int orientation = 0;
1637 _ControlRotation rotation = _ControlManager::GetInstance()->GetOrientationStatus();
1640 case _CONTROL_ROTATION_0:
1643 case _CONTROL_ROTATION_90:
1646 case _CONTROL_ROTATION_180:
1649 case _CONTROL_ROTATION_270:
1653 ewk_view_orientation_send(pView, orientation);
1655 OnWebPageBlockSelected(pUserData, pView, pEventInfo);
1660 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1662 String isMultipleSelection(L"single");
1663 result r = E_SUCCESS;
1666 String mode(L"selectionType");
1667 String type(L"type");
1668 _AppControlImpl* pMediaAppControlImpl = null;
1671 String fileType = L"all";
1675 isMultipleSelection.Append(L"multiple");
1678 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1679 SysTryReturn(NID_WEB_CTRL, pMediaAppControl.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1681 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1682 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1684 pMediaListener->Construct(pView, pMediaAppControl.get());
1686 itemCount = eina_list_count(pAcceptTypes);
1690 String item((char*)eina_list_nth(pAcceptTypes, 0));
1691 if (item.StartsWith("image/",0))
1693 fileType = L"image";
1695 else if (item.StartsWith("audio/",0))
1697 fileType = L"audio";
1699 else if (item.StartsWith("video/",0))
1701 fileType = L"video";
1705 r = dataList.Construct();
1706 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1708 r = dataList.Add(mode, isMultipleSelection);
1709 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1711 r = dataList.Add(type, fileType);
1712 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1714 pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl.get());
1715 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1716 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1718 pMediaListener.release();
1719 pMediaAppControl.release();
1724 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1730 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1732 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1733 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1734 SysAssertf(pImpl && pJsonText, "Failed to request");
1736 result r = E_SUCCESS;
1738 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1740 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1741 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1743 r = pEventArg->Construct(pJsonText);
1744 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1746 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1747 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1748 pEventArg.release();
1753 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1755 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1756 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1757 SysAssertf(pImpl && pEinaRect, "Failed to request");
1759 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1761 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1762 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1764 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1766 if (rect.height == 0)
1771 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1774 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1776 pImpl->SetFooterVisibleState(true);
1777 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1780 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1783 if (pImpl->GetWebKeypadEventListener())
1785 if (pImpl->IsKeypadVisible() == true)
1787 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1789 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1794 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1797 pImpl->SetKeypadVisibleState(true);
1798 pImpl->SetPreviousKeypadBounds(rect);
1802 result r = pImpl->SetFullScreenKeypad();
1803 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1809 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1811 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1812 SysAssertf(pImpl, "Failed to request");
1814 if (pImpl->GetWebKeypadEventListener())
1816 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1822 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1824 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1825 SysAssertf(pImpl, "Failed to request");
1827 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1830 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1832 pImpl->SetFooterVisibleState(false);
1833 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1836 pFormCore->DeflateClientRectHeight(0);
1839 if (pImpl->GetWebKeypadEventListener())
1841 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1844 pImpl->SetKeypadVisibleState(false);
1849 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1851 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1852 SysAssertf(pImpl, "Failed to request");
1854 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true)
1856 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1857 SysAssertf(pWebCore, "Failed to get Web core object");
1859 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1862 pImpl->SetKeypadOpened(false);
1867 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1869 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1870 SysAssertf(pImpl, "Failed to request");
1872 if (pImpl->IsKeypadOpened() == true)
1874 pImpl->SetKeypadOpened(false);
1876 pImpl->SetFocused();
1882 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1884 SysAssertf(pSmartData, "invalid smartdata");
1885 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1886 SysAssertf(pWebImpl, "Failed to get Impl");
1888 result r = E_SUCCESS;
1890 if (pWebImpl->GetColorpicker())
1897 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1898 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1900 byte r1, g1, b1, a1;
1901 color.GetColorComponents(r1, g1, b1, a1);
1902 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1909 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1911 SysAssertf(pSmartData, "invalid smartdata");
1913 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1914 SysAssertf(pWebImpl, "Failed to get Impl");
1916 return pWebImpl->HideColorPicker();
1921 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1923 SysAssertf(pSmartData, "Failed to request");
1924 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1925 SysAssertf(pWebImpl, "Failed to get Impl");
1927 result r = E_SUCCESS;
1929 if (pWebImpl->GetDatepicker())
1931 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1938 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1939 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1941 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1942 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1944 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1951 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1953 SysAssertf(pSmartData, "Failed to request");
1955 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1956 SysAssertf(pWebImpl, "Failed to get Impl");
1958 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1959 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1966 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1968 SysAssertf(pSmartData, "Failed to request");
1970 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1971 SysAssertf(pWebImpl, "Failed to get Impl");
1973 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1974 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1981 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1983 SysAssertf(pSmartData, "invalid smartdata");
1985 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1986 SysAssertf(pWebImpl, "Failed to get Impl");
1988 result r = pWebImpl->ClearSelectBoxPopup();
1989 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1996 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1998 SysAssertf(pSmartData, "invalid smartdata");
2000 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2001 SysAssertf(pWebImpl, "Failed to get Impl");
2003 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
2004 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2011 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
2013 SysAssertf(pSmartData, "Failed to request");
2015 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2016 SysAssertf(pWebImpl, "Failed to get Impl");
2018 Rectangle windowRect(x, y, w, h);
2019 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
2020 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2027 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
2029 SysAssertf(pSmartData, "Failed to request");
2031 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2032 SysAssertf(pWebImpl, "Failed to get Impl");
2034 if (pWebImpl->IsFormDataWindowVisible())
2036 pWebImpl->HideFormDataWindow();
2044 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
2046 SysAssertf(pSmartData, "Failed to request");
2048 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2049 SysAssertf(pWebImpl, "Failed to get Impl");
2051 pWebImpl->SetFormDataList(pDataList);
2058 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
2060 SysAssertf(pSmartData, "Failed to request");
2062 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2063 SysAssertf(pWebImpl, "Failed to get Impl");
2065 if (pWebImpl->IsFormDataWindowVisible())
2077 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2079 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2080 SysAssertf(pPresenter && !pError, "Failed to request");
2082 bool ret = EINA_TRUE;
2086 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2088 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2092 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2101 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2103 pPresenter->EndAsyncProcess(ret);
2108 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2110 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2111 SysAssertf(pPresenter, "Failed to request");
2113 String result(pResult);
2114 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2116 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2117 if (pImpl && pImpl->IsPresenterAlived(pPresenter))
2119 pPresenter->EndAsyncProcess(result);
2125 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2127 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2128 SysAssertf(pImpl, "Failed to request");
2130 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2131 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2133 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2137 pWebPresenter->EndAsyncProcess(*pTotalCount);
2141 if (pImpl->GetTextSearchListener())
2143 result r = E_SUCCESS;
2147 if (*pTotalCount > 0)
2149 ordinal = pImpl->GetAsyncSearchOrdinal();
2150 pImpl->SetAsyncSearchResult(*pTotalCount);
2153 if (pImpl->GetPendingAsyncSearchCount() > 0)
2158 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2159 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2160 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2161 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2163 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2164 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2167 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2168 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2171 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2172 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2173 pEventArg.release();
2179 class _JsBridgeHashCodeProvider
2180 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2183 _JsBridgeHashCodeProvider(){}
2184 virtual ~_JsBridgeHashCodeProvider(void) {}
2187 int GetHashCode(const Tizen::Base::String& obj) const
2189 return obj.GetHashCode();
2195 //Comparer implementation
2196 class _JsBridgeComparer
2197 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2200 _JsBridgeComparer(){}
2201 virtual ~_JsBridgeComparer(void) {}
2204 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2221 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2222 : _ContainerImpl(pWeb, pCore)
2223 , __isFooterVisible(false)
2224 , __isKeypadVisible(false)
2225 , __isKeypadOpened(false)
2226 , __isLoadingErrorOccurred(false)
2227 , __isRedirectRequested(false)
2228 , __isCertificateRequested(false)
2229 , __isCertificateConfirmed(false)
2230 , __isOrientationChanged(false)
2231 , __isFormDataVisible(false)
2232 , __keypadBounds(0, 0, 0, 0)
2234 , __pUserLoadingListener(null)
2235 , __pUserUiListener(null)
2236 , __pUserUiListenerF(null)
2237 , __pUserKeypadEventListener(null)
2238 , __pTextSearchListener(null)
2240 , __pJsBridgeList(null)
2241 , __pJsProvider(null)
2242 , __pJsComparer(null)
2243 , __pWebDownloadHandler(null)
2245 , __pAuthChallenge(null)
2246 , __pAuthPopup(null)
2247 , __pUserConfirmPopup(null)
2248 , __pPromptPopup(null)
2249 , __pCertConfirmPopup(null)
2250 , __pSelectBox(null)
2251 , __pDatePicker(null)
2252 , __pColorPicker(null)
2253 , __pFormDataWindow(null)
2255 , __policy(WEB_DECISION_CONTINUE)
2256 , __defaultUserAgent(L"")
2257 , __pFormDataList(null)
2259 __textSearch.__searchAll = false;
2260 __textSearch.__searchForward = true;
2261 __textSearch.__caseSensitive = false;
2262 __textSearch.__pending = 0;
2263 __textSearch.__currentIndex = 1;
2264 __textSearch.__totalCount = -1;
2265 __textSearch.__text = L"";
2269 _WebImpl::~_WebImpl()
2271 RemoveEventListenerCallback();
2272 ClearCertificateDb();
2277 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2279 result r = E_SUCCESS;
2281 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2282 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2284 _Web* pCore = _Web::CreateWebN();
2285 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2287 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2289 r = CheckConstruction(pCore, pImpl);
2290 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2292 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2293 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2295 r = pImpl->Construct();
2296 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2308 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2310 result r = E_SUCCESS;
2312 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2313 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2315 _Web* pCore = _Web::CreateWebN();
2316 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2318 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2320 r = CheckConstruction(pCore, pImpl);
2321 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2323 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2324 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2326 r = pImpl->Construct();
2327 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2339 _WebImpl::Construct(void)
2341 result r = E_SUCCESS;
2343 r = __mutex.Create();
2344 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2346 r = __textSearch.__searchQueue.Construct();
2347 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2349 r = __callbackList.Construct();
2350 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2352 r = InitJsBridgeList();
2353 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2356 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2358 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2359 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2366 _WebImpl::InitializeSetting(void)
2368 result r = E_SUCCESS;
2370 WebSetting* pWebSetting = __pWebCore->GetSetting();
2371 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2373 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2374 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2376 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2378 r = SetSetting(*pWebSetting);
2379 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2381 SetEventListenerCallback();
2388 _WebImpl::IsLayoutable(void) const
2395 _WebImpl::InitWebEvent(void)
2397 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2398 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2400 return __pWebEvent->Construct(*this);
2405 _WebImpl::GetWebEvent(void) const
2407 return __pWebEvent.get();
2412 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2414 Eina_Hash* pHttpHeader = null;
2416 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2417 if (pFieldNameList.get())
2419 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2420 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2422 int count = pFieldNameList->GetCount();
2424 for (int i = 0; i < count; i++)
2426 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2427 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2429 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2430 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2432 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2433 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2435 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2437 Eina_Bool ret = false;
2439 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2440 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2442 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2443 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2445 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2446 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2453 eina_hash_free(pHttpHeader);
2460 _WebImpl::LoadUrl(const String& url) const
2462 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2463 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2465 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2472 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2474 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2475 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2477 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2479 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2481 eina_hash_free(pHttpHeader);
2488 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2490 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2491 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2493 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2495 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2497 eina_hash_free(pHttpHeader);
2504 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2506 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2508 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2509 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2510 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2511 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2513 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2520 _WebImpl::Pause(void)
2522 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2527 _WebImpl::Resume(void)
2529 ewk_view_resume(__pWebCore->GetWebNativeNode());
2534 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2536 __pSelectBox.reset();
2538 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2540 result r = E_SUCCESS;
2542 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2543 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2545 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2546 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2548 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2549 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2551 __pSelectBox = std::move(pSelectBox);
2553 __pSelectBox->SetOwner(&GetPublic());
2555 return __pSelectBox->ShowPopup();
2560 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2562 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2564 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2569 _WebImpl::ClearSelectBoxPopup(void)
2571 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2573 __pSelectBox.reset();
2580 _WebImpl::GetDatepicker(void)
2582 _InputPickerPopup* pInputPicker =null;
2585 pInputPicker = __pDatePicker.get();
2587 return pInputPicker;
2592 _WebImpl::GetColorpicker(void)
2594 _InputPickerPopup* pInputPicker =null;
2597 pInputPicker = __pColorPicker.get();
2599 return pInputPicker;
2604 _WebImpl::CanGoBack(void) const
2606 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2611 _WebImpl::CanGoForward(void) const
2613 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2618 _WebImpl::GoBack(void) const
2620 ewk_view_back(__pWebCore->GetWebNativeNode());
2625 _WebImpl::GoForward(void) const
2627 ewk_view_forward(__pWebCore->GetWebNativeNode());
2632 _WebImpl::GetUrl(void) const
2634 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2639 _WebImpl::GetTitle(void) const
2641 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2646 _WebImpl::StopLoading(void) const
2648 ewk_view_stop(__pWebCore->GetWebNativeNode());
2653 _WebImpl::Reload(void) const
2655 ewk_view_reload(__pWebCore->GetWebNativeNode());
2660 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2662 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2668 result r = E_SUCCESS;
2670 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2671 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2673 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
2674 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2676 r = __callbackList.Add(pPresenter.get());
2677 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2679 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2681 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2682 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2683 pPresenter->WaitAsyncProcess(*pResult.get());
2685 r = __callbackList.Remove(*pPresenter.get());
2686 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2687 pPresenter.release();
2689 return pResult.release();
2694 _WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
2696 return __callbackList.Contains(*pPresenter);
2701 _WebImpl::SetZoomLevel(float level)
2703 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);
2705 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2712 _WebImpl::GetZoomLevel(void) const
2714 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2718 const PageNavigationList*
2719 _WebImpl::GetBackForwardListN(void) const
2721 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2727 result r = E_SUCCESS;
2729 _PageNavigationListImpl* pNavigationListImpl = null;
2730 _HistoryItemImpl* pHistoryItemImpl = null;
2732 std::unique_ptr<PageNavigationList> pNavigationList;
2733 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2736 int forwardCount = 0;
2741 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2742 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2744 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2745 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2747 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2748 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2750 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2751 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2753 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2754 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2756 r = pHistoryList->Construct();
2757 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2759 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2760 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2761 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2763 for (int i = -backCount; i < forwardCount + 1; i++)
2765 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2766 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2768 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2769 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2771 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2772 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2774 url = ewk_history_item_uri_get(pEwkItem);
2775 title = ewk_history_item_title_get(pEwkItem);
2776 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2778 pHistoryItemImpl->SetHistoryItem(url, title);
2780 r = pHistoryList->Add(*pHistoryItem.get());
2781 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2782 pHistoryItem.release();
2785 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2787 ewk_history_free(pEwkHistoryList);
2789 return pNavigationList.release();
2792 ewk_history_free(pEwkHistoryList);
2799 _WebImpl::SearchText(const String& text, bool searchForward)
2801 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2807 result r = E_SUCCESS;
2809 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2813 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2816 _WebPresenter presenter;
2817 presenter.InitAsyncProcess();
2819 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, &presenter);
2820 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2823 presenter.WaitAsyncProcess(result);
2825 return static_cast < bool >(result);
2830 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2832 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2838 result r = E_SUCCESS;
2840 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2844 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2847 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2848 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2855 _WebImpl::SearchNextAsync(bool searchForward)
2857 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2863 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2864 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2865 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2867 result r = E_SUCCESS;
2869 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2871 if (!__textSearch.__caseSensitive)
2873 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2878 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2881 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2882 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2889 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2891 MutexGuard lock(__mutex);
2893 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2894 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2899 if (__textSearch.__searchAll)
2901 DisableAsyncSearch();
2903 __textSearch.__searchQueue.Enqueue(this);
2904 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2906 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2907 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2911 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2913 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2917 case SEARCH_ALL_ASYNC:
2918 __textSearch.__searchAll = true;
2919 __textSearch.__text = text;
2920 __textSearch.__searchForward = true;
2921 __textSearch.__caseSensitive = caseSensitive;
2922 __textSearch.__totalCount = -1;
2923 __textSearch.__currentIndex = 1;
2925 __textSearch.__searchQueue.Enqueue(this);
2926 __textSearch.__searchQueue.Enqueue(this);
2928 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2929 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2932 case SEARCH_NEXT_ASYNC:
2933 __textSearch.__searchForward = searchForward;
2935 CalculateAsyncSearchOrdinal();
2937 __textSearch.__searchQueue.Enqueue(this);
2939 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2951 _WebImpl::SetAsyncSearchResult(int totalCount)
2953 __textSearch.__totalCount = totalCount;
2958 _WebImpl::GetSearchPresenter(void)
2960 MutexGuard lock(__mutex);
2962 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2967 _WebImpl::GetPendingAsyncSearchCount(void) const
2969 return __textSearch.__searchQueue.GetCount();
2974 _WebImpl::CalculateAsyncSearchOrdinal(void)
2976 if (__textSearch.__searchForward)
2978 __textSearch.__currentIndex++;
2982 __textSearch.__currentIndex--;
2988 _WebImpl::GetAsyncSearchOrdinal(void) const
2990 return __textSearch.__currentIndex;
2995 _WebImpl::DisableAsyncSearch(void)
2997 __textSearch.__searchAll = false;
3002 _WebImpl::SetSetting(const WebSetting& setting)
3004 if (__pWebCore->GetWebNativeNode())
3006 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3007 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3008 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
3010 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
3011 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3013 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
3015 switch (setting.GetCacheControl())
3017 case WEB_CACHE_VALIDATED:
3018 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
3021 case WEB_CACHE_IGNORE:
3022 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
3029 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
3031 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
3035 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
3038 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
3040 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
3042 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
3044 if (__defaultUserAgent != setting.GetUserAgent())
3046 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
3047 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3049 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
3052 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
3054 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
3056 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3058 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3061 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3063 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3064 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3065 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3066 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3067 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3068 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3069 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3070 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3071 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3072 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3073 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3074 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3075 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3082 _WebImpl::GetSetting(void) const
3084 return *__pWebCore->GetSetting();
3088 const HitElementResult*
3089 _WebImpl::GetElementByPointN(const Point& point) const
3091 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3095 const HitElementResult*
3096 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3098 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3104 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));
3106 result r = E_SUCCESS;
3108 _HitElementResultImpl* pHitElementResultImpl = null;
3110 std::unique_ptr<HitElementResult> pHitElementResult;
3111 std::unique_ptr<Bitmap> pImage;
3112 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3114 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3116 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3117 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3119 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3120 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3121 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3122 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3123 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3125 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3127 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3128 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3130 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3131 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3133 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3139 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3140 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3141 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3142 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3144 r = buf.Construct(imageLength);
3145 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3147 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3148 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3152 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3153 // webkit support types such as ico and vp8 additionally
3154 if (strcmp(pExtension, "gif") == 0)
3156 format = IMG_FORMAT_GIF;
3158 else if (strcmp(pExtension, "jpg") == 0)
3160 format = IMG_FORMAT_JPG;
3162 else if (strcmp(pExtension, "png") == 0)
3164 format = IMG_FORMAT_PNG;
3166 else if (strcmp(pExtension, "bmp") == 0)
3168 format = IMG_FORMAT_BMP;
3172 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3176 r = image.Construct();
3177 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3179 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3180 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3185 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3186 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3188 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3189 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3191 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3192 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3195 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3197 ewk_hit_test_free(pEwkHitTest);
3199 return pHitElementResult.release();
3202 ewk_hit_test_free(pEwkHitTest);
3209 _WebImpl::IsLoading(void) const
3211 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3213 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3225 _WebImpl::GetTextFromBlock(void) const
3227 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3232 _WebImpl::IsPrivateBrowsingEnabled(void) const
3234 if (__pWebCore->GetWebNativeNode() == null)
3236 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3239 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3240 SysAssertf(pSettings, "Failed to get webkit instance.");
3242 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3247 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3249 if (__pWebCore->GetWebNativeNode() == null)
3251 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3255 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3256 SysAssertf(pSettings, "Failed to get webkit instance.");
3258 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3263 _WebImpl::ClearHistory(void)
3265 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3270 _WebImpl::ClearCache(void)
3272 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3274 ewk_context_cache_clear(pContext);
3279 _WebImpl::ClearCookie(void)
3281 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3282 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3284 ewk_cookie_manager_cookies_clear(pCookieManager);
3289 _WebImpl::ClearFormData(void)
3291 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3293 ewk_context_form_candidate_data_clear(pContext);
3298 _WebImpl::ClearLoginFormData(void)
3300 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3302 ewk_context_form_password_data_clear(pContext);
3307 _WebImpl::IsCookieEnabled(void) const
3309 if (__pWebCore->GetWebNativeNode() == null)
3311 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3314 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3315 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3316 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3318 _WebPresenter presenter;
3319 presenter.InitAsyncProcess();
3321 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3323 bool result = false;
3324 presenter.WaitAsyncProcess(result);
3331 _WebImpl::SetCookieEnabled(bool enable)
3333 if (__pWebCore->GetWebNativeNode() == null)
3335 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3340 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3341 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3342 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3346 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3350 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3351 ewk_cookie_manager_cookies_clear(pCookieManager);
3357 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3359 result r = E_SUCCESS;
3361 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3362 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3365 String fileExtension = File::GetFileExtension(filePath);
3366 int pathLength = filePath.GetLength();
3369 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3371 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3372 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3373 r = filePath.SubString(0, index + 1, dirPath);
3374 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3376 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3377 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3381 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3383 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3387 Evas_Coord contentsWidth;
3388 Evas_Coord contentsHeight;
3390 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3391 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3399 _WebImpl::IsMimeSupported(const String& mime) const
3401 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3402 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3404 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3409 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3411 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3416 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3418 __pUserUiListener = pUiEventListener;
3423 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3425 __pUserUiListenerF = pUiEventListener;
3430 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3432 __pUserKeypadEventListener = pKeypadEventListener;
3437 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3439 if (__pWebDownloadHandler.get() == null)
3441 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3442 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3445 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3446 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3451 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3453 __pTextSearchListener = pTextSearchListener;
3458 _WebImpl::SetScrollEnabled(bool enable)
3460 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3465 _WebImpl::IsScrollEnabled(void) const
3467 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3472 _WebImpl::InitJsBridgeList(void)
3474 result r = E_SUCCESS;
3476 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3477 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3479 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3480 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3482 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3483 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3485 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3486 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3488 __pJsBridgeList = std::move(pJsBridgeList);
3495 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3497 result r = E_SUCCESS;
3499 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3500 String key(pJsBridge->GetName());
3502 r = __pJsBridgeList->Add(key, pJsBridge);
3503 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3510 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3512 result r = E_SUCCESS;
3514 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3515 String key(pJsBridge->GetName());
3517 r = __pJsBridgeList->Remove(key);
3518 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3525 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3527 result r = E_SUCCESS;
3529 IJsonValue* pJsonValue = null;
3530 IJavaScriptBridge* pJsBridge = null;
3532 String key(L"name");
3534 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3535 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));
3537 r = pJsonObject->GetValue(&key, pJsonValue);
3538 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3540 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3541 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3543 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3544 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3551 _WebImpl::GetLoadingListener(void) const
3553 return __pUserLoadingListener;
3557 IWebUiEventListener*
3558 _WebImpl::GetUiEventListener(void) const
3560 return __pUserUiListener;
3564 IWebUiEventListenerF*
3565 _WebImpl::GetUiEventListenerF(void) const
3567 return __pUserUiListenerF;
3571 IWebKeypadEventListener*
3572 _WebImpl::GetWebKeypadEventListener(void) const
3574 return __pUserKeypadEventListener;
3578 ITextSearchListener*
3579 _WebImpl::GetTextSearchListener(void) const
3581 return __pTextSearchListener;
3586 _WebImpl::SetEventListenerCallback(void) const
3588 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3591 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3592 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3594 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3595 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3597 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3598 SysAssertf(pSmartData, "Failed to request");
3600 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3601 SysAssertf(pSmart, "Failed to request");
3603 pSmart->popup_menu_show = OnSelectBoxRequested;
3604 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3605 pSmart->popup_menu_hide = OnSelectBoxClosed;
3606 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3608 pSmart->input_picker_show = OnDatePickerProviderRequested;
3609 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3610 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3612 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3613 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3614 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3615 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3617 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3619 // add loading event callbacks for ILoadingListener
3620 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3621 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3623 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3624 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3625 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3626 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3627 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3628 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3629 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3630 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3631 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3633 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3635 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3637 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3638 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3639 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3641 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3642 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3644 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3646 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3647 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3648 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3650 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3652 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3653 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3654 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3656 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3657 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3658 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3660 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3661 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3662 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3664 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3665 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3666 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3667 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3669 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3670 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3672 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3673 evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this);
3675 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3676 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3677 SysAssertf(pContext, "Failed to get webkit instance.");
3678 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3679 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3681 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3682 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3683 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3684 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3686 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3692 _WebImpl::RemoveEventListenerCallback(void) const
3694 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3697 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3698 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3700 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3701 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3703 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3704 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3706 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3707 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3708 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3709 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3710 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3711 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3712 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3713 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3715 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3717 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3719 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3720 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3721 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3723 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3724 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3726 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3728 ewk_view_javascript_alert_callback_set(null, null, null);
3729 ewk_view_javascript_prompt_callback_set(null, null, null);
3730 ewk_view_javascript_confirm_callback_set(null, null, null);
3732 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3734 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3735 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3736 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3738 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3739 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3740 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3741 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3742 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3743 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3745 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3746 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3747 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3749 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3751 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3752 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3754 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3755 evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation);
3757 ewk_view_open_panel_callback_set(null, null, null);
3758 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3759 SysAssertf(pContext, "Failed to get webkit instance.");
3760 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3762 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3763 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3764 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3765 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3767 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3773 _WebImpl::ClearCertificateDb(void)
3775 result r = E_SUCCESS;
3777 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3778 String table(CERTIFICATE_TABLE_NAME);
3781 r = db.Construct(certificatePath, "r+", null);
3782 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3784 db.BeginTransaction();
3786 r = db.ExecuteSql(L"Delete From " + table, true);
3787 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3789 db.CommitTransaction();
3794 db.RollbackTransaction();
3799 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3801 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3806 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3808 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3809 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
3810 if (pSmartData && pSmartData->api)
3812 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3814 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3817 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3819 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3820 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3822 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3824 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3826 ewk_view_command_execute(pView, "SelectWord", 0);
3830 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3831 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3834 ewk_view_command_execute(pView, "SelectWord", 0);
3840 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3847 _WebImpl::ReleaseBlock(void)
3849 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3854 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3856 FloatPoint tempStartPoint;
3857 FloatPoint tempEndPoint;
3859 GetBlockRange(tempStartPoint, tempEndPoint);
3861 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3862 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3867 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3869 Eina_Rectangle leftHandle;
3870 Eina_Rectangle rightHandle;
3872 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3873 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3875 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3877 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3878 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3879 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3880 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3882 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3884 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3885 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3891 _WebImpl::GetFaviconN(void) const
3893 result r = E_SUCCESS;
3895 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3896 Ewk_Context* pContext = ewk_view_context_get(pView);
3897 const char* pUrl = ewk_view_url_get(pView);
3898 Evas* pEvas = evas_object_evas_get(pView);
3900 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3906 Tizen::Graphics::BufferInfo bufferInfo;
3908 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3909 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3911 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3912 Tizen::Base::ByteBuffer byteBuffer;
3914 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3915 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3917 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3918 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3920 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3921 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3923 return pImage.release();
3929 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3931 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3936 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3938 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3943 _WebImpl::GetScrollPosition(void) const
3947 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3954 _WebImpl::GetPageSize(void) const
3956 Evas_Coord width = 0;
3957 Evas_Coord height = 0;
3959 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3961 Dimension size(static_cast< int >(width), static_cast< int >(height));
3968 _WebImpl::SetLoadingErrorOccurred(bool arg)
3970 __isLoadingErrorOccurred = arg;
3975 _WebImpl::IsLoadingErrorOccurred(void) const
3977 return __isLoadingErrorOccurred;
3982 _WebImpl::SetRedirectRequested(bool arg)
3984 __isRedirectRequested = arg;
3989 _WebImpl::IsRedirectRequested(void) const
3991 return __isRedirectRequested;
3996 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
4003 _WebImpl::GetPolicyDecision(void) const
4010 _WebImpl::SetCertificateRequested(bool arg)
4012 __isCertificateRequested = arg;
4017 _WebImpl::IsCertificateRequested(void) const
4019 return __isCertificateRequested;
4024 _WebImpl::SetCertificateConfirmed(bool arg)
4026 __isCertificateConfirmed = arg;
4031 _WebImpl::IsCertificateConfirmed(void) const
4033 return __isCertificateConfirmed;
4038 _WebImpl::SetOrientationChanged(bool arg)
4040 __isOrientationChanged = arg;
4045 _WebImpl::IsOrientationChanged(void) const
4047 return __isOrientationChanged;
4052 _WebImpl::LaunchAppControl(const IEventArg& arg)
4054 result r = E_SUCCESS;
4056 IEventArg* pArg = const_cast< IEventArg* >(&arg);
4057 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
4058 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
4060 String operationId(L"");
4061 String uriPattern(pWebEventArg->GetEventMessage());
4062 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
4064 switch (pWebEventArg->GetEventType())
4066 case WEB_EVENT_REQUEST_RTSP:
4070 int uriLength = uriPattern.GetLength();
4073 operationId = L"http://tizen.org/appcontrol/operation/view";
4075 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
4076 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4078 r = uriPattern.SubString(index + 1, ext);
4079 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4081 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
4082 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4084 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
4085 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4089 case WEB_EVENT_REQUEST_TEL:
4091 operationId = L"http://tizen.org/appcontrol/operation/dial";
4094 case WEB_EVENT_REQUEST_EMAIL:
4096 case WEB_EVENT_REQUEST_SMS:
4098 case WEB_EVENT_REQUEST_MMS:
4100 operationId = L"http://tizen.org/appcontrol/operation/compose";
4103 case WEB_EVENT_REQUEST_UNKNOWN:
4105 operationId = L"http://tizen.org/appcontrol/operation/view";
4113 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
4114 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4121 _WebImpl::SetFullScreenKeypad(void)
4123 result r = E_SUCCESS;
4125 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4126 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4128 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4129 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4131 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4132 pKeypad->SetText(text);
4134 r = pKeypad->SetShowState(true);
4135 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4137 r = pKeypad->Show();
4138 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4140 pKeypad->AddTextEventListener(*this);
4142 __pKeypad = std::move(pKeypad);
4149 _WebImpl::RemoveFullScreenKeypad(void)
4151 __pKeypad->RemoveTextEventListener(*this);
4158 _WebImpl::IsFooterVisible(void) const
4160 return __isFooterVisible;
4165 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4167 __isFooterVisible = isFooterVisible;
4172 _WebImpl::IsKeypadVisible(void) const
4174 return __isKeypadVisible;
4179 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4181 __isKeypadVisible = isKeypadVisible;
4186 _WebImpl::IsKeypadOpened(void) const
4188 return __isKeypadOpened;
4192 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4194 __isKeypadOpened = isKeypadOpened;
4199 _WebImpl::GetPreviousKeypadBounds(void) const
4201 return __keypadBounds;
4206 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4208 __keypadBounds = bounds;
4213 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4215 RemoveFullScreenKeypad();
4220 _WebImpl::OnTextValueChanged(const Control& source)
4222 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4224 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4226 RemoveFullScreenKeypad();
4231 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4233 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4234 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4236 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4237 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4239 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4240 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4242 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4249 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4251 result r = E_SUCCESS;
4253 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4254 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4256 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4258 ILoadingListener* pLoadingListner = GetLoadingListener();
4259 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4261 switch (pEventArg->GetEventType())
4263 case WEB_EVENT_LOADINGLISTENER_STARTED:
4265 pLoadingListner->OnLoadingStarted();
4269 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4271 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4272 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4274 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4278 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4280 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4281 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4283 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4287 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4289 pLoadingListner->OnLoadingCanceled();
4293 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4295 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4296 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4298 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4299 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4301 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4303 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4307 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4309 pLoadingListner->OnLoadingCompleted();
4313 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4315 pLoadingListner->OnHttpAuthenticationCanceled();
4319 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4321 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4322 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4326 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4342 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4344 result r = E_SUCCESS;
4346 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4347 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4349 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4351 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4352 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4354 switch (pEventArg->GetEventType())
4356 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4358 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4359 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4361 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4365 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4367 pWebDownloadListener->OnWebDataDownloadCompleted();
4371 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4373 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4374 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4376 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4378 pWebDownloadListener->OnWebDownloadFailed(errorType);
4393 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4395 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4396 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4398 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4400 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4402 switch (pEventArg->GetEventType())
4404 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4406 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4408 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4409 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4411 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4412 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4414 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4418 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4420 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4422 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4426 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4428 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4430 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4434 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4436 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4438 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4439 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4441 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4456 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4458 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4459 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4461 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4463 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4465 switch (pEventArg->GetEventType())
4467 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4469 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4471 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4472 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4474 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4475 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4477 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4481 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4483 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4485 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4489 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4491 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4493 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4497 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4499 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4501 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4502 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4504 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4519 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4521 result r = E_SUCCESS;
4523 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4524 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4526 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4528 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4529 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4531 switch (pEventArg->GetEventType())
4533 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4535 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4536 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4538 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4539 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4541 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4556 _WebImpl::VibrationRequested(uint64_t duration)
4558 result r = E_SUCCESS;
4560 __pVibrator.reset();
4562 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4563 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4565 r = pVibrator->Construct();
4566 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4568 __pVibrator = std::move(pVibrator);
4570 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4572 r = __pVibrator->Start(&pattern, 1, 1);
4573 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4580 _WebImpl::VibrationCanceled(void)
4582 __pVibrator.reset();
4587 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4589 result r = E_SUCCESS;
4591 String host(ewk_auth_challenge_url_get(pChallenge));
4592 String realm(ewk_auth_challenge_realm_get(pChallenge));
4594 __pAuthChallenge.reset();
4596 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4597 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4599 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4600 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4602 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4603 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4605 __pAuthChallenge = std::move(pAuthChallenge);
4607 ewk_auth_challenge_suspend(pChallenge);
4608 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4610 __pAuthChallenge.release();
4614 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4615 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4623 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4625 result r = E_SUCCESS;
4627 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4628 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4630 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4631 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4633 __pAuthPopup = std::move(pAuthPopup);
4635 int modalResult = 0;
4637 __pAuthPopup->SetOwner(&GetPublic());
4639 r = __pAuthPopup->ShowAndWait(modalResult);
4640 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4643 __pAuthPopup.reset();
4650 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4652 result r = E_SUCCESS;
4654 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4655 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4657 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4658 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4660 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4662 int modalResult = 0;
4664 __pCertConfirmPopup->SetOwner(&GetPublic());
4666 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4667 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4669 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4671 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4675 __pCertConfirmPopup.reset();
4682 _WebImpl::ShowPromptPopup(String msg, String defVal)
4684 result r = E_SUCCESS;
4686 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4687 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4689 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode());
4690 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4692 __pPromptPopup = std::move(pPromptPopup);
4694 __pPromptPopup->SetOwner(&GetPublic());
4696 r = __pPromptPopup->ShowPopup();
4697 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4702 __pPromptPopup.reset();
4710 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4712 result r = E_SUCCESS;
4714 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4715 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4717 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
4718 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4720 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4722 int modalResult = 0;
4724 __pUserConfirmPopup->SetOwner(&GetPublic());
4726 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4727 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4730 __pUserConfirmPopup.reset();
4737 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4739 result r = E_SUCCESS;
4741 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4742 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4744 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
4745 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4747 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4749 __pUserConfirmPopup->SetOwner(&GetPublic());
4751 r = __pUserConfirmPopup->ShowPopup();
4752 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4754 __pUserConfirmPopup.release();
4759 __pUserConfirmPopup.reset();
4766 _WebImpl::GetParentFormCore(_Control* pControlCore)
4769 _Form* pFormCore = null;
4771 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4772 if (!pParentControlCore)
4777 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4783 return GetParentFormCore(pParentControlCore);
4788 _WebImpl::OnFocusGained(const _ControlImpl& source)
4795 _WebImpl::OnFocusLost(const _ControlImpl& source)
4797 if(IsKeypadVisible() == true)
4799 SetKeypadOpened(true);
4801 SetKeypadVisibleState(false);
4804 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4811 _WebImpl::HasValidNativeNode(void) const
4813 if (__pWebCore && __pWebCore->GetWebNativeNode())
4823 _WebImpl::OnPreAttachedToMainTree(void)
4825 result r = E_SUCCESS;
4827 r = __pWebCore->InitializeWebNativeNode();
4828 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4830 r = InitializeSetting();
4831 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4833 r = _ContainerImpl::OnPreAttachedToMainTree();
4834 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4841 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4843 _ContainerImpl::OnChangeLayout(orientation);
4845 if (__pColorPicker.get())
4847 __pColorPicker->ChangeLayout(orientation);
4850 HideFormDataWindow();
4852 __isOrientationChanged = true;
4857 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4859 if (IsVisible() == true)
4861 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4865 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4871 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4875 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4876 __pCertConfirmPopup.reset();
4878 case ID_PROMPT_POPUP_CLOSE:
4879 __pPromptPopup.reset();
4881 case ID_USER_CONFIRM_POPUP_CLOSE:
4882 __pUserConfirmPopup.reset();
4891 _WebImpl::GetDownloadHandler(void) const
4893 return __pWebDownloadHandler.get();
4898 _WebImpl::HideColorPicker(void)
4900 __pColorPicker.reset();
4907 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4909 result r = E_SUCCESS;
4911 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4912 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4914 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4916 r = pColorHadler->Construct(colorVal, this);
4917 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4919 __pColorPicker = std::move(pColorHadler);
4921 r = __pColorPicker->ShowPopup();
4922 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4924 color = __pColorPicker->GetColor();
4929 __pColorPicker.reset();
4936 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4938 result r = E_SUCCESS;
4940 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4941 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4943 r = pInputPicker->Construct(String(inputValue), inputType, this);
4944 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4946 __pDatePicker = std::move(pInputPicker);
4948 r = __pDatePicker->ShowPopup();
4949 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4951 dateStr = __pDatePicker->GetDate();
4954 __pDatePicker.reset();
4961 _WebImpl::GetInstance(Web* pWeb)
4963 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4968 _WebImpl::GetInstance(const Web* pWeb)
4970 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4975 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4977 int checkReturn = 0;
4979 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4982 if( checkmime == true)
4984 table = CUSTOM_CONTENT_TABLE_NAME;
4988 table = CUSTOM_PROTOCOL_TABLE_NAME;
4991 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4992 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4993 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4995 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4997 result r = db.Construct(handlerPath, "r+", null);
4998 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5000 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"'"));
5001 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5005 r = pEnum->MoveNext();
5006 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5007 r = pEnum->GetIntAt(0, checkReturn);
5008 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5020 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5024 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5027 if( checkmime == true)
5029 table = CUSTOM_CONTENT_TABLE_NAME;
5033 table = CUSTOM_PROTOCOL_TABLE_NAME;
5036 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5037 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5038 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5040 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5042 result r = db.Construct(handlerPath, "r+", null);
5043 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5045 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"'"));
5046 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5050 r = pEnum->MoveNext();
5051 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5052 r = pEnum->GetIntAt(0, checkId);
5053 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5055 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5056 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5058 r = pDeleteStmt->BindInt(0, checkId);
5059 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5061 db.BeginTransaction();
5063 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5065 db.CommitTransaction();
5072 const Tizen::Base::String
5073 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5075 if (originUri == L"" || currentUri == L"")
5080 result r = E_SUCCESS;
5083 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5084 String originReplace(originUri);
5085 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5089 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5090 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5092 r = currentUri.SubString(0, found + 1, baseUri);
5093 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5095 r = db.Construct(handlerPath, "r+", null);
5096 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5098 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5099 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5103 while (pEnum->MoveNext() == E_SUCCESS)
5108 String originScheme;
5110 r = pEnum->GetStringAt(0, protocol);
5111 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5113 r = pEnum->GetStringAt(1, queryUrl);
5114 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5116 r = pEnum->GetIntAt(2, allow);
5117 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5124 String protocolScheme(protocol + L":");
5126 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5127 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5129 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5131 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5133 r = originReplace.Replace(originScheme, "");
5134 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5136 queryUrl.Replace("%s", originReplace, 0);
5137 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5149 const Tizen::Base::String
5150 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5152 if (originUri == L"" || currentUri == L"" || mime == L"")
5157 result r = E_SUCCESS;
5160 String originUrlStr = originUri;
5161 const String replaceStr = L"%s";
5163 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5164 String table(CUSTOM_CONTENT_TABLE_NAME);
5168 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5169 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5171 r = currentUri.SubString(0, found + 1, baseUri);
5172 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5174 r = db.Construct(handlerPath, "r+", null);
5175 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5177 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5181 r = pEnum->MoveNext();
5182 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5183 r = pEnum->GetIntAt(0, allow);
5184 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5185 r = pEnum->GetStringAt(1, contentUrl);
5186 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5194 if (contentUrl != L"")
5196 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5197 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5209 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5211 __pFormDataList = pFormDataList;
5216 _WebImpl::IsFormDataWindowVisible(void) const
5218 return __isFormDataVisible;
5223 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5225 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5227 if (__isFormDataVisible)
5229 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5230 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5234 __pFormDataWindow.reset();
5236 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5237 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5239 result r = pFormDataWindow->Construct(rect, this, pWebView);
5240 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5242 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5243 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5245 r = pFormDataWindow->LaunchFormDataWindow();
5246 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5248 __pFormDataWindow = std::move(pFormDataWindow);
5249 __isFormDataVisible = true;
5257 _WebImpl::HideFormDataWindow(bool delWindow)
5261 __pFormDataWindow.reset();
5264 __isFormDataVisible = false;
5269 _WebImpl::OnDownloadCompleted(RequestId reqId, const String &path)
5271 _ContentManagerImpl::ScanFile(path);
5275 }}} // Tizen::Web::Controls