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 pImpl->SetWebNotification(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 if (uriScheme == L"tel")
948 String operationId(L"http://tizen.org/appcontrol/operation/dial");
949 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
951 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
953 String operationId(L"http://tizen.org/appcontrol/operation/compose");
954 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
958 String operationId(L"http://tizen.org/appcontrol/operation/view");
959 String mime(ewk_policy_decision_response_mime_get(pPolicy));
960 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
962 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
967 ewk_policy_decision_use(pPolicy);
972 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
974 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
975 SysAssertf(pImpl, "Failed to request");
977 if (pImpl->GetLoadingListener())
979 result r = E_SUCCESS;
981 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
982 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
984 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
985 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
992 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
994 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
995 char* pTitle = reinterpret_cast< char* >(pEventInfo);
996 SysAssertf(pImpl, "Failed to request");
998 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1000 if (pImpl->GetLoadingListener())
1002 result r = E_SUCCESS;
1004 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1005 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1006 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1008 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1009 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1010 pPageTitle.release();
1012 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1013 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1014 pEventArg.release();
1020 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1022 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1023 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1024 SysAssertf(pImpl, "Failed to request");
1026 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1028 if (pImpl->GetLoadingListener())
1030 result r = E_SUCCESS;
1032 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1033 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1034 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1036 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1037 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1038 pProgressPercentage.release();
1040 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1041 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1042 pEventArg.release();
1048 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1050 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1051 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1052 SysAssertf(pImpl && pPolicy, "Failed to request");
1054 result r = E_SUCCESS;
1056 _SystemResource* pSysResource = _SystemResource::GetInstance();
1057 SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
1059 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1060 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1061 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1062 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1064 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1066 String url(ewk_policy_decision_url_get(pPolicy));
1068 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1070 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1072 DecisionPolicy policy;
1073 HttpHeader httpHeader;
1075 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1077 pImpl->SetRedirectRequested(true);
1081 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1082 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1084 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1085 pImpl->SetPolicyDecision(policy);
1088 switch (pImpl->GetPolicyDecision())
1090 case WEB_DECISION_CONTINUE:
1092 String currentUrl(pImpl->GetUrl());
1093 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1094 if (redirectUrl != L"")
1096 pImpl->LoadUrl(redirectUrl);
1097 ewk_policy_decision_ignore(pPolicy);
1102 if (pImpl->IsMimeSupported(mime) || mime == L"")
1109 ewk_policy_decision_ignore(pPolicy);
1111 _SelectBox selectBox;
1112 int selectedIndex = 0;
1113 String operationId(L"http://tizen.org/appcontrol/operation/view");
1115 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1116 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1118 if (r == E_OBJ_NOT_FOUND)
1120 r = selectBox.Construct(false, L"Select application", 1); //+1 for Downloader
1121 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1123 selectBox.AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1124 r = selectBox.ShowAndWait(selectedIndex);
1125 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1127 if (selectedIndex == 0) //download
1129 RequestId reqId = 0;
1130 DownloadRequest request(pUrl);
1132 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1133 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1135 r = pManagerImpl->Start(request, reqId);
1136 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1144 case WEB_DECISION_DOWNLOAD:
1146 ewk_policy_decision_ignore(pPolicy);
1148 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1149 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1151 Ewk_Context* pContext = ewk_view_context_get(pView);
1152 SysAssertf(pContext, "Failed to get webkit instance.");
1154 pDownloadHandler->StartDownload(pUrl);
1158 case WEB_DECISION_IGNORE:
1160 ewk_policy_decision_ignore(pPolicy);
1170 ewk_policy_decision_use(pPolicy);
1175 ewk_policy_decision_ignore(pPolicy);
1180 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1182 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1183 SysAssertf(pImpl, "Failed to request");
1185 if (pImpl->IsRedirectRequested())
1187 pImpl->SetRedirectRequested(false);
1190 if (pImpl->IsLoadingErrorOccurred())
1192 pImpl->SetLoadingErrorOccurred(false);
1193 evas_object_smart_callback_call(pView, "load,finished", NULL);
1199 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1201 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1202 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1203 SysAssertf(pImpl && pErrorData, "Failed to request");
1205 int code = ewk_error_code_get(pErrorData);
1206 const char* pDescription = ewk_error_description_get(pErrorData);
1208 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1212 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1213 pImpl->SetLoadingErrorOccurred(true);
1216 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1217 evas_object_smart_callback_call(pView, "load,finished", NULL);
1220 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1221 pImpl->SetLoadingErrorOccurred(true);
1222 evas_object_smart_callback_call(pView, "load,stop", NULL);
1226 pImpl->SetLoadingErrorOccurred(true);
1227 if (pImpl->GetLoadingListener())
1229 result r = E_SUCCESS;
1231 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1232 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1240 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1242 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1243 SysAssertf(pImpl, "Failed to request");
1245 if (pImpl->GetLoadingListener())
1247 result r = E_SUCCESS;
1249 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1250 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1252 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1253 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1254 pEventArg.release();
1261 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1263 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1264 SysAssertf(pImpl, "Failed to request");
1266 if (pImpl->GetLoadingListener())
1268 result r = E_SUCCESS;
1270 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1271 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1273 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1274 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1275 pEventArg.release();
1282 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1284 evas_object_focus_set(pView, EINA_FALSE);
1289 OnFaviconReceived(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_FAVICON_RECEIVED));
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 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1312 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1313 SysAssertf(pUrl && pImpl != null, "Failed to request");
1315 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1320 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1322 result r = E_SUCCESS;
1324 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1325 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1327 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1328 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1329 pEventArg.release();
1336 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1338 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1339 SysAssertf(pImpl, "Failed to request");
1341 if (pImpl->GetUiEventListener())
1343 result r = E_SUCCESS;
1345 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1346 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1348 if (pImpl->GetUiEventListenerF())
1350 result r = E_SUCCESS;
1352 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1353 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1359 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1361 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1362 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1363 SysAssertf(pParentImpl && pChildView, "Failed to request");
1365 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1366 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1367 if (pUserUiListener)
1369 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1372 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1373 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1375 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1376 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1379 if (pUserUiListenerF)
1381 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1384 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1385 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1387 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1388 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1395 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1397 result r = E_SUCCESS;
1399 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1400 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1402 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1403 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1404 pEventArg.release();
1411 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1413 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1414 SysAssertf(pChildImpl, "Failed to request");
1416 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1417 if (pParentImpl == null)
1422 if (pParentImpl->GetUiEventListener())
1424 result r = E_SUCCESS;
1426 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1427 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1429 if (pParentImpl->GetUiEventListenerF())
1431 result r = E_SUCCESS;
1433 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1434 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1440 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1442 result r = E_SUCCESS;
1444 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1445 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1446 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1448 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1449 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1450 pPreventTrigger.release();
1452 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1453 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1454 pEventArg.release();
1461 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1463 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1464 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1465 SysAssertf(pImpl && pTrigger, "Failed to request");
1467 if (pImpl->GetUiEventListener())
1469 result r = E_SUCCESS;
1471 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1472 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1474 if (pImpl->GetUiEventListenerF())
1476 result r = E_SUCCESS;
1478 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1479 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1485 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1487 result r = E_SUCCESS;
1489 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1490 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1491 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1493 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1495 if ((endPoint->x != 0) && (endPoint->y != 0))
1497 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1498 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1500 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1501 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1502 startPoint.release();
1504 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1505 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1508 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1509 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1510 pEventArg.release();
1518 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1520 result r = E_SUCCESS;
1522 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1523 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1525 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1527 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1529 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1531 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1532 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1534 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1535 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1536 startPoint.release();
1538 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1539 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1542 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1543 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1544 pEventArg.release();
1552 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1554 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1555 SysAssertf(pImpl, "Failed to request");
1557 if (pImpl->GetUiEventListener())
1559 result r = E_SUCCESS;
1561 r = FireWebPageBlockSelectedEvent(pImpl);
1562 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1564 if (pImpl->GetUiEventListenerF())
1566 result r = E_SUCCESS;
1568 r = FireWebPageBlockSelectedEventF(pImpl);
1569 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1575 OnWebPageBlockSelectedByOrientation(void* pUserData, Evas_Object* pView, void* pEventInfo)
1577 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1578 SysAssertf(pImpl, "Failed to request");
1580 if (!pImpl->IsOrientationChanged())
1585 pImpl->SetOrientationChanged(false);
1587 int orientation = 0;
1588 _ControlRotation rotation = _ControlManager::GetInstance()->GetOrientationStatus();
1591 case _CONTROL_ROTATION_0:
1594 case _CONTROL_ROTATION_90:
1597 case _CONTROL_ROTATION_180:
1600 case _CONTROL_ROTATION_270:
1604 ewk_view_orientation_send(pView, orientation);
1606 OnWebPageBlockSelected(pUserData, pView, pEventInfo);
1611 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1613 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1614 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1616 pMediaListener->Construct(pView);
1619 result r = extraData.Construct();
1620 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_TRUE, r, "[%s] Propagating.", GetErrorMessage(r));
1622 String isMultipleSelection(L"single");
1623 String mode(L"selectionType");
1624 String type(L"type");
1625 String fileType = L"*/*";
1626 String operationId = L"http://tizen.org/appcontrol/operation/pick";
1630 isMultipleSelection.Append(L"multiple");
1633 if (eina_list_count(pAcceptTypes) == 1)
1635 String item((char*)eina_list_nth(pAcceptTypes, 0));
1636 String captureString(pCapture);
1638 if (item.StartsWith("image/",0))
1640 if (captureString == L"camera")
1642 fileType = L"image/jpg";
1643 operationId = L"http://tizen.org/appcontrol/operation/create_content";
1644 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
1645 String typeVal = L"false";
1646 extraData.Add(&typeKey, &typeVal);
1650 fileType = L"image/*";
1651 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1652 extraData.Add(&selectKey, &isMultipleSelection);
1655 else if (item.StartsWith("audio/",0))
1657 fileType = L"audio/*";
1658 //TO DO: as microphone is not supported yet. suggest to throw an exception
1659 //if (captureString == L"microphone")
1661 //operationId = L"http://tizen.org/appcontrol/operation/create_content";
1665 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1666 extraData.Add(&selectKey, &isMultipleSelection);
1669 else if (item.StartsWith("video/",0))
1671 if (captureString == L"camcorder")
1673 fileType = L"video/3gpp";
1674 operationId = L"http://tizen.org/appcontrol/operation/create_content";
1675 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
1676 String typeVal = L"false";
1677 extraData.Add(&typeKey, &typeVal);
1681 fileType = L"video/*";
1682 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1683 extraData.Add(&selectKey, &isMultipleSelection);
1688 r = _AppControlImpl::FindAndStart(operationId, null, &fileType, null, &extraData, pMediaListener.get());
1689 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1691 pMediaListener.release();
1696 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1702 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1704 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1705 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1706 SysAssertf(pImpl && pJsonText, "Failed to request");
1708 result r = E_SUCCESS;
1710 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1712 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1713 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1715 r = pEventArg->Construct(pJsonText);
1716 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1718 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1719 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1720 pEventArg.release();
1725 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1727 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1728 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1729 SysAssertf(pImpl && pEinaRect, "Failed to request");
1731 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1733 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1734 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1736 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1738 if (rect.height == 0)
1743 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1746 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1748 if (pFormCore->HasFooter())
1750 pFormCore->SetKeypadShowState(true);
1755 if (pImpl->GetWebKeypadEventListener())
1757 if (pImpl->IsKeypadVisible() == true)
1759 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1761 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1766 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1769 pImpl->SetKeypadVisibleState(true);
1770 pImpl->SetPreviousKeypadBounds(rect);
1774 result r = pImpl->SetFullScreenKeypad();
1775 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1781 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1783 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1784 SysAssertf(pImpl, "Failed to request");
1786 if (pImpl->GetWebKeypadEventListener())
1788 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1794 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1796 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1797 SysAssertf(pImpl, "Failed to request");
1799 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1802 pFormCore->DeflateClientRectHeight(0);
1804 if (pFormCore->HasFooter())
1806 pFormCore->SetKeypadShowState(false);
1811 if (pImpl->GetWebKeypadEventListener())
1813 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1816 pImpl->SetKeypadVisibleState(false);
1821 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1823 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1824 SysAssertf(pImpl, "Failed to request");
1826 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true)
1828 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1829 SysAssertf(pWebCore, "Failed to get Web core object");
1831 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1834 pImpl->SetKeypadOpened(false);
1839 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1841 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1842 SysAssertf(pImpl, "Failed to request");
1844 if (pImpl->IsKeypadOpened() == true)
1846 pImpl->SetKeypadOpened(false);
1848 pImpl->SetFocused();
1854 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1856 SysAssertf(pSmartData, "invalid smartdata");
1857 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1858 SysAssertf(pWebImpl, "Failed to get Impl");
1860 result r = E_SUCCESS;
1862 if (pWebImpl->GetColorpicker())
1869 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1870 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1872 byte r1, g1, b1, a1;
1873 color.GetColorComponents(r1, g1, b1, a1);
1874 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1881 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1883 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 return pWebImpl->HideColorPicker();
1893 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1895 SysAssertf(pSmartData, "Failed to request");
1896 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1897 SysAssertf(pWebImpl, "Failed to get Impl");
1899 result r = E_SUCCESS;
1901 if (pWebImpl->GetDatepicker())
1903 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1910 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1911 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1913 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1914 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1916 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1923 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1925 SysAssertf(pSmartData, "Failed to request");
1927 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1928 SysAssertf(pWebImpl, "Failed to get Impl");
1930 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1931 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1938 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1940 SysAssertf(pSmartData, "Failed to request");
1942 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1943 SysAssertf(pWebImpl, "Failed to get Impl");
1945 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1946 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1953 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1955 SysAssertf(pSmartData, "invalid smartdata");
1957 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1958 SysAssertf(pWebImpl, "Failed to get Impl");
1960 result r = pWebImpl->ClearSelectBoxPopup();
1961 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1968 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1970 SysAssertf(pSmartData, "invalid smartdata");
1972 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1973 SysAssertf(pWebImpl, "Failed to get Impl");
1975 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1976 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1983 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1985 SysAssertf(pSmartData, "Failed to request");
1987 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1988 SysAssertf(pWebImpl, "Failed to get Impl");
1990 Rectangle windowRect(x, y, w, h);
1991 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1992 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1999 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
2001 SysAssertf(pSmartData, "Failed to request");
2003 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2004 SysAssertf(pWebImpl, "Failed to get Impl");
2006 if (pWebImpl->IsFormDataWindowVisible())
2008 pWebImpl->HideFormDataWindow();
2016 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
2018 SysAssertf(pSmartData, "Failed to request");
2020 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2021 SysAssertf(pWebImpl, "Failed to get Impl");
2023 pWebImpl->SetFormDataList(pDataList);
2030 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
2032 SysAssertf(pSmartData, "Failed to request");
2034 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2035 SysAssertf(pWebImpl, "Failed to get Impl");
2037 if (pWebImpl->IsFormDataWindowVisible())
2049 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2051 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2052 SysAssertf(pPresenter && !pError, "Failed to request");
2054 bool ret = EINA_TRUE;
2058 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2060 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2064 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2073 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2075 pPresenter->EndAsyncProcess(ret);
2080 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2082 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2083 SysAssertf(pPresenter, "Failed to request");
2085 String result(pResult);
2086 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2088 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2089 if (pImpl && pImpl->IsPresenterAlived(pPresenter))
2091 pPresenter->EndAsyncProcess(result);
2097 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2099 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2100 SysAssertf(pImpl, "Failed to request");
2102 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2103 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2105 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2109 pWebPresenter->EndAsyncProcess(*pTotalCount);
2113 if (pImpl->GetTextSearchListener())
2115 result r = E_SUCCESS;
2119 if (*pTotalCount > 0)
2121 ordinal = pImpl->GetAsyncSearchOrdinal();
2122 pImpl->SetAsyncSearchResult(*pTotalCount);
2125 if (pImpl->GetPendingAsyncSearchCount() > 0)
2130 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2131 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2132 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2133 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2135 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2136 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2139 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2140 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2143 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2144 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2145 pEventArg.release();
2151 class _JsBridgeHashCodeProvider
2152 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2155 _JsBridgeHashCodeProvider(){}
2156 virtual ~_JsBridgeHashCodeProvider(void) {}
2159 int GetHashCode(const Tizen::Base::String& obj) const
2161 return obj.GetHashCode();
2167 //Comparer implementation
2168 class _JsBridgeComparer
2169 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2172 _JsBridgeComparer(){}
2173 virtual ~_JsBridgeComparer(void) {}
2176 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2193 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2194 : _ContainerImpl(pWeb, pCore)
2195 , __isFooterVisible(false)
2196 , __isKeypadVisible(false)
2197 , __isKeypadOpened(false)
2198 , __isLoadingErrorOccurred(false)
2199 , __isRedirectRequested(false)
2200 , __isCertificateRequested(false)
2201 , __isCertificateConfirmed(false)
2202 , __isOrientationChanged(false)
2203 , __isFormDataVisible(false)
2204 , __keypadBounds(0, 0, 0, 0)
2206 , __pUserLoadingListener(null)
2207 , __pUserUiListener(null)
2208 , __pUserUiListenerF(null)
2209 , __pUserKeypadEventListener(null)
2210 , __pTextSearchListener(null)
2212 , __pJsBridgeList(null)
2213 , __pJsProvider(null)
2214 , __pJsComparer(null)
2215 , __pWebDownloadHandler(null)
2217 , __pAuthChallenge(null)
2218 , __pAuthPopup(null)
2219 , __pUserMediaConfirmPopup(null)
2220 , __pContentHandlerConfirmPopup(null)
2221 , __pProtocolHandlerConfirmPopup(null)
2222 , __pGeolocationConfirmPopup(null)
2223 , __pNotificationConfirmPopup(null)
2224 , __pScriptAlertConfirmPopup(null)
2225 , __pAppCacheConfirmPopup(null)
2226 , __pDbQuotaConfirmPopup(null)
2227 , __pLocalFsQuotaConfirmPopup(null)
2228 , __pIndexedDbQuotaConfirmPopup(null)
2229 , __pPromptPopup(null)
2230 , __pCertConfirmPopup(null)
2231 , __pSelectBox(null)
2232 , __pDatePicker(null)
2233 , __pColorPicker(null)
2234 , __pFormDataWindow(null)
2236 , __policy(WEB_DECISION_CONTINUE)
2237 , __defaultUserAgent(L"")
2238 , __pFormDataList(null)
2240 __textSearch.__searchAll = false;
2241 __textSearch.__searchForward = true;
2242 __textSearch.__caseSensitive = false;
2243 __textSearch.__pending = 0;
2244 __textSearch.__currentIndex = 1;
2245 __textSearch.__totalCount = -1;
2246 __textSearch.__text = L"";
2250 _WebImpl::~_WebImpl()
2252 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2253 pManagerImpl->SetDownloadListener(null);
2255 RemoveEventListenerCallback();
2256 ClearCertificateDb();
2261 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2263 result r = E_SUCCESS;
2265 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2266 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2268 _Web* pCore = _Web::CreateWebN();
2269 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2271 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2273 r = CheckConstruction(pCore, pImpl);
2274 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2276 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2277 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2279 r = pImpl->Construct();
2280 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2292 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2294 result r = E_SUCCESS;
2296 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2297 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2299 _Web* pCore = _Web::CreateWebN();
2300 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2302 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2304 r = CheckConstruction(pCore, pImpl);
2305 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2307 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2308 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2310 r = pImpl->Construct();
2311 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2323 _WebImpl::Construct(void)
2325 result r = E_SUCCESS;
2327 r = __mutex.Create();
2328 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2330 r = __textSearch.__searchQueue.Construct();
2331 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2333 r = __callbackList.Construct();
2334 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2336 r = __webNotificationList.Construct();
2337 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2339 r = InitJsBridgeList();
2340 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2343 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2345 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2346 SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2348 pManagerImpl->SetDownloadListener(this);
2350 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2351 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2358 _WebImpl::InitializeSetting(void)
2360 result r = E_SUCCESS;
2362 WebSetting* pWebSetting = __pWebCore->GetSetting();
2363 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2365 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2366 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2368 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2370 r = SetSetting(*pWebSetting);
2371 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2373 SetEventListenerCallback();
2380 _WebImpl::IsLayoutable(void) const
2387 _WebImpl::InitWebEvent(void)
2389 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2390 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2392 return __pWebEvent->Construct(*this);
2397 _WebImpl::GetWebEvent(void) const
2399 return __pWebEvent.get();
2404 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2406 Eina_Hash* pHttpHeader = null;
2408 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2409 if (pFieldNameList.get())
2411 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2412 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2414 int count = pFieldNameList->GetCount();
2416 for (int i = 0; i < count; i++)
2418 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2419 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2421 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2422 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2424 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2425 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2427 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2429 Eina_Bool ret = false;
2431 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2432 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2434 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2435 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2437 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2438 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2445 eina_hash_free(pHttpHeader);
2452 _WebImpl::LoadUrl(const String& url) const
2454 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2455 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2457 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2464 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2466 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2467 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2469 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2471 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2473 eina_hash_free(pHttpHeader);
2480 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2482 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2483 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2485 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2487 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2489 eina_hash_free(pHttpHeader);
2496 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2498 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2500 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2501 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2502 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2503 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2505 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2512 _WebImpl::Pause(void)
2514 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2519 _WebImpl::Resume(void)
2521 ewk_view_resume(__pWebCore->GetWebNativeNode());
2526 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2528 __pSelectBox.reset();
2530 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2532 result r = E_SUCCESS;
2534 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2535 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2537 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2538 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2540 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2541 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2543 __pSelectBox = std::move(pSelectBox);
2545 __pSelectBox->SetOwner(&GetPublic());
2547 return __pSelectBox->ShowPopup();
2552 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2554 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2556 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2561 _WebImpl::ClearSelectBoxPopup(void)
2563 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2565 __pSelectBox.reset();
2572 _WebImpl::GetDatepicker(void)
2574 _InputPickerPopup* pInputPicker =null;
2577 pInputPicker = __pDatePicker.get();
2579 return pInputPicker;
2584 _WebImpl::GetColorpicker(void)
2586 _InputPickerPopup* pInputPicker =null;
2589 pInputPicker = __pColorPicker.get();
2591 return pInputPicker;
2596 _WebImpl::CanGoBack(void) const
2598 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2603 _WebImpl::CanGoForward(void) const
2605 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2610 _WebImpl::GoBack(void) const
2612 ewk_view_back(__pWebCore->GetWebNativeNode());
2617 _WebImpl::GoForward(void) const
2619 ewk_view_forward(__pWebCore->GetWebNativeNode());
2624 _WebImpl::GetUrl(void) const
2626 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2631 _WebImpl::GetTitle(void) const
2633 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2638 _WebImpl::StopLoading(void) const
2640 ewk_view_stop(__pWebCore->GetWebNativeNode());
2645 _WebImpl::Reload(void) const
2647 ewk_view_reload(__pWebCore->GetWebNativeNode());
2652 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2654 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2660 result r = E_SUCCESS;
2662 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2663 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2665 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
2666 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2668 r = __callbackList.Add(pPresenter.get());
2669 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2671 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2673 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2674 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2675 pPresenter->WaitAsyncProcess(*pResult.get());
2677 r = __callbackList.Remove(*pPresenter.get());
2678 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2679 pPresenter.release();
2681 return pResult.release();
2686 _WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
2688 return __callbackList.Contains(*pPresenter);
2693 _WebImpl::SetZoomLevel(float level)
2695 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);
2697 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2704 _WebImpl::GetZoomLevel(void) const
2706 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2710 const PageNavigationList*
2711 _WebImpl::GetBackForwardListN(void) const
2713 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2719 result r = E_SUCCESS;
2721 _PageNavigationListImpl* pNavigationListImpl = null;
2722 _HistoryItemImpl* pHistoryItemImpl = null;
2724 std::unique_ptr<PageNavigationList> pNavigationList;
2725 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2728 int forwardCount = 0;
2733 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2734 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2736 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2737 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2739 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2740 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2742 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2743 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2745 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2746 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2748 r = pHistoryList->Construct();
2749 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2751 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2752 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2753 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2755 for (int i = -backCount; i < forwardCount + 1; i++)
2757 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2758 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2760 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2761 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2763 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2764 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2766 url = ewk_history_item_uri_get(pEwkItem);
2767 title = ewk_history_item_title_get(pEwkItem);
2768 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2770 pHistoryItemImpl->SetHistoryItem(url, title);
2772 r = pHistoryList->Add(*pHistoryItem.get());
2773 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2774 pHistoryItem.release();
2777 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2779 ewk_history_free(pEwkHistoryList);
2781 return pNavigationList.release();
2784 ewk_history_free(pEwkHistoryList);
2791 _WebImpl::SearchText(const String& text, bool searchForward)
2793 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2799 result r = E_SUCCESS;
2801 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2805 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2808 _WebPresenter presenter;
2809 presenter.InitAsyncProcess();
2811 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, &presenter);
2812 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2815 presenter.WaitAsyncProcess(result);
2817 return static_cast < bool >(result);
2822 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2824 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2830 result r = E_SUCCESS;
2832 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2836 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2839 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2840 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2847 _WebImpl::SearchNextAsync(bool searchForward)
2849 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2855 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2856 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2857 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2859 result r = E_SUCCESS;
2861 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2863 if (!__textSearch.__caseSensitive)
2865 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2870 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2873 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2874 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2881 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2883 MutexGuard lock(__mutex);
2885 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2886 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2891 if (__textSearch.__searchAll)
2893 DisableAsyncSearch();
2895 __textSearch.__searchQueue.Enqueue(this);
2896 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2898 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2899 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2903 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2905 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2909 case SEARCH_ALL_ASYNC:
2910 __textSearch.__searchAll = true;
2911 __textSearch.__text = text;
2912 __textSearch.__searchForward = true;
2913 __textSearch.__caseSensitive = caseSensitive;
2914 __textSearch.__totalCount = -1;
2915 __textSearch.__currentIndex = 1;
2917 __textSearch.__searchQueue.Enqueue(this);
2918 __textSearch.__searchQueue.Enqueue(this);
2920 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2921 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2924 case SEARCH_NEXT_ASYNC:
2925 __textSearch.__searchForward = searchForward;
2927 CalculateAsyncSearchOrdinal();
2929 __textSearch.__searchQueue.Enqueue(this);
2931 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2943 _WebImpl::SetAsyncSearchResult(int totalCount)
2945 __textSearch.__totalCount = totalCount;
2950 _WebImpl::GetSearchPresenter(void)
2952 MutexGuard lock(__mutex);
2954 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2959 _WebImpl::GetPendingAsyncSearchCount(void) const
2961 return __textSearch.__searchQueue.GetCount();
2966 _WebImpl::CalculateAsyncSearchOrdinal(void)
2968 if (__textSearch.__searchForward)
2970 __textSearch.__currentIndex++;
2974 __textSearch.__currentIndex--;
2980 _WebImpl::GetAsyncSearchOrdinal(void) const
2982 return __textSearch.__currentIndex;
2987 _WebImpl::DisableAsyncSearch(void)
2989 __textSearch.__searchAll = false;
2994 _WebImpl::SetSetting(const WebSetting& setting)
2996 if (__pWebCore->GetWebNativeNode())
2998 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2999 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3000 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
3002 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
3003 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3005 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
3007 switch (setting.GetCacheControl())
3009 case WEB_CACHE_VALIDATED:
3010 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
3013 case WEB_CACHE_IGNORE:
3014 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
3021 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
3023 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
3027 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
3030 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
3032 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
3034 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
3036 if (__defaultUserAgent != setting.GetUserAgent())
3038 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
3039 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3041 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
3044 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
3046 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
3048 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3050 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3053 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3055 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3056 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3057 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3058 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3059 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3060 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3061 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3062 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3063 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3064 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3065 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3066 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3067 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3074 _WebImpl::GetSetting(void) const
3076 return *__pWebCore->GetSetting();
3080 const HitElementResult*
3081 _WebImpl::GetElementByPointN(const Point& point) const
3083 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3087 const HitElementResult*
3088 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3090 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3096 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));
3098 result r = E_SUCCESS;
3100 _HitElementResultImpl* pHitElementResultImpl = null;
3102 std::unique_ptr<HitElementResult> pHitElementResult;
3103 std::unique_ptr<Bitmap> pImage;
3104 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3106 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3108 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3109 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3111 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3112 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3113 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3114 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3115 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3117 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3119 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3120 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3122 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3123 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3125 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3131 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3132 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3133 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3134 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3136 r = buf.Construct(imageLength);
3137 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3139 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3140 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3144 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3145 // webkit support types such as ico and vp8 additionally
3146 if (strcmp(pExtension, "gif") == 0)
3148 format = IMG_FORMAT_GIF;
3150 else if (strcmp(pExtension, "jpg") == 0)
3152 format = IMG_FORMAT_JPG;
3154 else if (strcmp(pExtension, "png") == 0)
3156 format = IMG_FORMAT_PNG;
3158 else if (strcmp(pExtension, "bmp") == 0)
3160 format = IMG_FORMAT_BMP;
3164 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3168 r = image.Construct();
3169 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3171 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3172 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3177 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3178 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3180 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3181 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3183 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3184 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3187 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3189 ewk_hit_test_free(pEwkHitTest);
3191 return pHitElementResult.release();
3194 ewk_hit_test_free(pEwkHitTest);
3201 _WebImpl::IsLoading(void) const
3203 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3205 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3217 _WebImpl::GetTextFromBlock(void) const
3219 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3224 _WebImpl::IsPrivateBrowsingEnabled(void) const
3226 if (__pWebCore->GetWebNativeNode() == null)
3228 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3231 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3232 SysAssertf(pSettings, "Failed to get webkit instance.");
3234 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3239 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3241 if (__pWebCore->GetWebNativeNode() == null)
3243 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3247 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3248 SysAssertf(pSettings, "Failed to get webkit instance.");
3250 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3255 _WebImpl::ClearHistory(void)
3257 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3262 _WebImpl::ClearCache(void)
3264 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3266 ewk_context_cache_clear(pContext);
3271 _WebImpl::ClearCookie(void)
3273 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3274 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3276 ewk_cookie_manager_cookies_clear(pCookieManager);
3281 _WebImpl::ClearFormData(void)
3283 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3285 ewk_context_form_candidate_data_clear(pContext);
3290 _WebImpl::ClearLoginFormData(void)
3292 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3294 ewk_context_form_password_data_clear(pContext);
3299 _WebImpl::IsCookieEnabled(void) const
3301 if (__pWebCore->GetWebNativeNode() == null)
3303 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3306 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3307 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3308 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3310 _WebPresenter presenter;
3311 presenter.InitAsyncProcess();
3313 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3315 bool result = false;
3316 presenter.WaitAsyncProcess(result);
3323 _WebImpl::SetCookieEnabled(bool enable)
3325 if (__pWebCore->GetWebNativeNode() == null)
3327 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3332 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3333 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3334 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3338 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3342 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3343 ewk_cookie_manager_cookies_clear(pCookieManager);
3349 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3351 result r = E_SUCCESS;
3353 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3354 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3357 String fileExtension = File::GetFileExtension(filePath);
3358 int pathLength = filePath.GetLength();
3361 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3363 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3364 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3365 r = filePath.SubString(0, index + 1, dirPath);
3366 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3368 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3369 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3373 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3375 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3379 Evas_Coord contentsWidth;
3380 Evas_Coord contentsHeight;
3382 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3383 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3391 _WebImpl::IsMimeSupported(const String& mime) const
3393 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3394 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3396 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3401 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3403 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3408 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3410 __pUserUiListener = pUiEventListener;
3415 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3417 __pUserUiListenerF = pUiEventListener;
3422 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3424 __pUserKeypadEventListener = pKeypadEventListener;
3429 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3431 if (__pWebDownloadHandler.get() == null)
3433 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3434 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3437 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3438 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3443 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3445 __pTextSearchListener = pTextSearchListener;
3450 _WebImpl::SetScrollEnabled(bool enable)
3452 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3457 _WebImpl::IsScrollEnabled(void) const
3459 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3464 _WebImpl::InitJsBridgeList(void)
3466 result r = E_SUCCESS;
3468 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3469 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3471 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3472 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3474 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3475 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3477 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3478 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3480 __pJsBridgeList = std::move(pJsBridgeList);
3487 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3489 result r = E_SUCCESS;
3491 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3492 String key(pJsBridge->GetName());
3494 r = __pJsBridgeList->Add(key, pJsBridge);
3495 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3502 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3504 result r = E_SUCCESS;
3506 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3507 String key(pJsBridge->GetName());
3509 r = __pJsBridgeList->Remove(key);
3510 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3517 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3519 result r = E_SUCCESS;
3521 IJsonValue* pJsonValue = null;
3522 IJavaScriptBridge* pJsBridge = null;
3524 String key(L"name");
3526 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3527 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));
3529 r = pJsonObject->GetValue(&key, pJsonValue);
3530 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3532 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3533 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3535 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3536 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3543 _WebImpl::GetLoadingListener(void) const
3545 return __pUserLoadingListener;
3549 IWebUiEventListener*
3550 _WebImpl::GetUiEventListener(void) const
3552 return __pUserUiListener;
3556 IWebUiEventListenerF*
3557 _WebImpl::GetUiEventListenerF(void) const
3559 return __pUserUiListenerF;
3563 IWebKeypadEventListener*
3564 _WebImpl::GetWebKeypadEventListener(void) const
3566 return __pUserKeypadEventListener;
3570 ITextSearchListener*
3571 _WebImpl::GetTextSearchListener(void) const
3573 return __pTextSearchListener;
3578 _WebImpl::SetEventListenerCallback(void) const
3580 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3583 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3584 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3586 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3587 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3589 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3590 SysAssertf(pSmartData, "Failed to request");
3592 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3593 SysAssertf(pSmart, "Failed to request");
3595 pSmart->popup_menu_show = OnSelectBoxRequested;
3596 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3597 pSmart->popup_menu_hide = OnSelectBoxClosed;
3598 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3600 pSmart->input_picker_show = OnDatePickerProviderRequested;
3601 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3602 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3604 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3605 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3606 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3607 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3609 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3611 // add loading event callbacks for ILoadingListener
3612 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3613 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3615 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3616 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3617 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3618 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3619 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3620 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3621 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3622 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3623 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3625 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3627 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3629 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3630 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3631 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3633 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3634 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3636 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3638 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3639 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3640 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3642 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3644 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3645 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3646 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3648 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3649 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3650 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3652 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3653 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3654 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3656 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3657 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3658 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3659 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3661 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3662 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3664 evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
3665 evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this);
3667 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3668 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3669 SysAssertf(pContext, "Failed to get webkit instance.");
3670 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3671 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3673 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3674 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3675 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3676 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3678 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3684 _WebImpl::RemoveEventListenerCallback(void) const
3686 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3689 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3690 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3692 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3693 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3695 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3696 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3698 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3699 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3700 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3701 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3702 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3703 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3704 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3705 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3707 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3709 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3711 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3712 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3713 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3715 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3716 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3718 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3720 ewk_view_javascript_alert_callback_set(null, null, null);
3721 ewk_view_javascript_prompt_callback_set(null, null, null);
3722 ewk_view_javascript_confirm_callback_set(null, null, null);
3724 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3726 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3727 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3728 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3730 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3731 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3732 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3733 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3734 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3735 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3737 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3738 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3739 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3741 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3743 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3744 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3746 evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
3747 evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation);
3749 ewk_view_open_panel_callback_set(null, null, null);
3750 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3751 SysAssertf(pContext, "Failed to get webkit instance.");
3752 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3754 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3755 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3756 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3757 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3759 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3765 _WebImpl::ClearCertificateDb(void)
3767 result r = E_SUCCESS;
3769 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3770 String table(CERTIFICATE_TABLE_NAME);
3773 r = db.Construct(certificatePath, "r+", null);
3774 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3776 db.BeginTransaction();
3778 r = db.ExecuteSql(L"Delete From " + table, true);
3779 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3781 db.CommitTransaction();
3786 db.RollbackTransaction();
3791 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3793 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3798 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3800 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3801 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
3802 if (pSmartData && pSmartData->api)
3804 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3806 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3809 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3811 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3812 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3814 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3816 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3818 ewk_view_command_execute(pView, "SelectWord", 0);
3822 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3823 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3826 ewk_view_command_execute(pView, "SelectWord", 0);
3832 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3834 evas_object_smart_callback_call(pView, "text,selected", NULL);
3841 _WebImpl::ReleaseBlock(void)
3843 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3848 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3850 FloatPoint tempStartPoint;
3851 FloatPoint tempEndPoint;
3853 GetBlockRange(tempStartPoint, tempEndPoint);
3855 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3856 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3861 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3863 Eina_Rectangle leftHandle;
3864 Eina_Rectangle rightHandle;
3866 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3867 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3869 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3871 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3872 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3873 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3874 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3876 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3878 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3879 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3885 _WebImpl::GetFaviconN(void) const
3887 result r = E_SUCCESS;
3889 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3890 Ewk_Context* pContext = ewk_view_context_get(pView);
3891 const char* pUrl = ewk_view_url_get(pView);
3892 Evas* pEvas = evas_object_evas_get(pView);
3894 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3900 Tizen::Graphics::BufferInfo bufferInfo;
3902 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3903 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3905 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3906 Tizen::Base::ByteBuffer byteBuffer;
3908 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3909 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3911 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3912 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3914 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3915 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3917 return pImage.release();
3923 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3925 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3930 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3932 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3937 _WebImpl::GetScrollPosition(void) const
3941 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3948 _WebImpl::GetPageSize(void) const
3950 Evas_Coord width = 0;
3951 Evas_Coord height = 0;
3953 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3955 Dimension size(static_cast< int >(width), static_cast< int >(height));
3962 _WebImpl::SetLoadingErrorOccurred(bool arg)
3964 __isLoadingErrorOccurred = arg;
3969 _WebImpl::IsLoadingErrorOccurred(void) const
3971 return __isLoadingErrorOccurred;
3976 _WebImpl::SetRedirectRequested(bool arg)
3978 __isRedirectRequested = arg;
3983 _WebImpl::IsRedirectRequested(void) const
3985 return __isRedirectRequested;
3990 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3997 _WebImpl::GetPolicyDecision(void) const
4004 _WebImpl::SetCertificateRequested(bool arg)
4006 __isCertificateRequested = arg;
4011 _WebImpl::IsCertificateRequested(void) const
4013 return __isCertificateRequested;
4018 _WebImpl::SetCertificateConfirmed(bool arg)
4020 __isCertificateConfirmed = arg;
4025 _WebImpl::IsCertificateConfirmed(void) const
4027 return __isCertificateConfirmed;
4032 _WebImpl::SetOrientationChanged(bool arg)
4034 __isOrientationChanged = arg;
4039 _WebImpl::IsOrientationChanged(void) const
4041 return __isOrientationChanged;
4046 _WebImpl::SetFullScreenKeypad(void)
4048 result r = E_SUCCESS;
4050 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4051 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4053 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4054 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4056 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4057 pKeypad->SetText(text);
4059 r = pKeypad->SetShowState(true);
4060 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4062 r = pKeypad->Show();
4063 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4065 pKeypad->AddTextEventListener(*this);
4067 __pKeypad = std::move(pKeypad);
4074 _WebImpl::RemoveFullScreenKeypad(void)
4076 __pKeypad->RemoveTextEventListener(*this);
4083 _WebImpl::IsFooterVisible(void) const
4085 return __isFooterVisible;
4090 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4092 __isFooterVisible = isFooterVisible;
4097 _WebImpl::IsKeypadVisible(void) const
4099 return __isKeypadVisible;
4104 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4106 __isKeypadVisible = isKeypadVisible;
4111 _WebImpl::IsKeypadOpened(void) const
4113 return __isKeypadOpened;
4117 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4119 __isKeypadOpened = isKeypadOpened;
4124 _WebImpl::GetPreviousKeypadBounds(void) const
4126 return __keypadBounds;
4131 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4133 __keypadBounds = bounds;
4138 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4140 RemoveFullScreenKeypad();
4145 _WebImpl::OnTextValueChanged(const Control& source)
4147 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4149 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4151 RemoveFullScreenKeypad();
4156 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4158 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4159 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4161 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4162 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4164 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4165 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4167 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4174 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4176 result r = E_SUCCESS;
4178 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4179 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4181 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4183 ILoadingListener* pLoadingListner = GetLoadingListener();
4184 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4186 switch (pEventArg->GetEventType())
4188 case WEB_EVENT_LOADINGLISTENER_STARTED:
4190 pLoadingListner->OnLoadingStarted();
4194 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4196 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4197 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4199 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4203 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4205 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4206 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4208 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4212 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4214 pLoadingListner->OnLoadingCanceled();
4218 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4220 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4221 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4223 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4224 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4226 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4228 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4232 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4234 pLoadingListner->OnLoadingCompleted();
4238 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4240 pLoadingListner->OnHttpAuthenticationCanceled();
4244 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4246 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4247 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4251 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4267 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4269 result r = E_SUCCESS;
4271 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4272 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4274 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4276 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4277 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4279 switch (pEventArg->GetEventType())
4281 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4283 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4284 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4286 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4290 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4292 pWebDownloadListener->OnWebDataDownloadCompleted();
4296 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4298 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4299 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4301 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4303 pWebDownloadListener->OnWebDownloadFailed(errorType);
4318 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4320 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4321 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4323 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4325 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4327 switch (pEventArg->GetEventType())
4329 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4331 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4333 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4334 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4336 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4337 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4339 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4343 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4345 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4347 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4351 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4353 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4355 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4359 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4361 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4363 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4364 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4366 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4381 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4383 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4384 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4386 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4388 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4390 switch (pEventArg->GetEventType())
4392 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4394 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4396 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4397 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4399 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4400 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4402 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4406 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4408 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4410 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4414 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4416 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4418 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4422 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4424 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4426 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4427 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4429 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4444 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4446 result r = E_SUCCESS;
4448 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4449 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4451 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4453 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4454 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4456 switch (pEventArg->GetEventType())
4458 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4460 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4461 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4463 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4464 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4466 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4481 _WebImpl::VibrationRequested(uint64_t duration)
4483 result r = E_SUCCESS;
4485 __pVibrator.reset();
4487 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4488 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4490 r = pVibrator->Construct();
4491 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4493 __pVibrator = std::move(pVibrator);
4495 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4497 r = __pVibrator->Start(&pattern, 1, 1);
4498 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4505 _WebImpl::VibrationCanceled(void)
4507 __pVibrator.reset();
4512 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4514 result r = E_SUCCESS;
4516 String host(ewk_auth_challenge_url_get(pChallenge));
4517 String realm(ewk_auth_challenge_realm_get(pChallenge));
4519 __pAuthChallenge.reset();
4521 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4522 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4524 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4525 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4527 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4528 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4530 __pAuthChallenge = std::move(pAuthChallenge);
4532 ewk_auth_challenge_suspend(pChallenge);
4533 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4535 __pAuthChallenge.release();
4539 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4540 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4548 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4550 result r = E_SUCCESS;
4552 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4553 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4555 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4556 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4558 __pAuthPopup = std::move(pAuthPopup);
4560 int modalResult = 0;
4562 __pAuthPopup->SetOwner(&GetPublic());
4564 r = __pAuthPopup->ShowAndWait(modalResult);
4565 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4568 __pAuthPopup.reset();
4575 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4577 result r = E_SUCCESS;
4579 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4580 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4582 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4583 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4585 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4587 int modalResult = 0;
4589 __pCertConfirmPopup->SetOwner(&GetPublic());
4591 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4592 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4594 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4596 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4600 __pCertConfirmPopup.reset();
4607 _WebImpl::ShowPromptPopup(String msg, String defVal)
4609 result r = E_SUCCESS;
4611 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4612 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4614 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode());
4615 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4617 __pPromptPopup = std::move(pPromptPopup);
4619 __pPromptPopup->SetOwner(&GetPublic());
4621 r = __pPromptPopup->ShowPopup();
4622 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4627 __pPromptPopup.reset();
4635 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4637 result r = E_SUCCESS;
4639 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4640 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4642 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
4643 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4645 pUserConfirmPopup->SetOwner(&GetPublic());
4647 int modalResult = 0;
4649 switch(userConfirmMode)
4651 case USER_CONTENT_HANDLER:
4653 __pContentHandlerConfirmPopup.reset();
4655 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4657 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4658 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4661 case USER_PROTOCOL_HANDLER:
4663 __pProtocolHandlerConfirmPopup.reset();
4665 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4667 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4668 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4671 case USER_CONFIRM_APP_CACHE:
4673 __pAppCacheConfirmPopup.reset();
4675 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4677 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4678 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4681 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4683 __pDbQuotaConfirmPopup.reset();
4685 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4687 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4688 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4691 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4693 __pLocalFsQuotaConfirmPopup.reset();
4695 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4697 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4698 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4701 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4703 __pIndexedDbQuotaConfirmPopup.reset();
4705 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4707 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4708 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4718 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4720 result r = E_SUCCESS;
4722 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4723 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4725 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
4726 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4728 pUserConfirmPopup->SetOwner(&GetPublic());
4730 switch(userConfirmMode)
4732 case USER_CONFIRM_USERMEDIA:
4734 __pUserMediaConfirmPopup.reset();
4736 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4738 r = __pUserMediaConfirmPopup->ShowPopup();
4739 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4741 __pUserMediaConfirmPopup.release();
4744 case USER_CONFIRM_GEOLOCATION:
4746 __pGeolocationConfirmPopup.reset();
4748 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4750 r = __pGeolocationConfirmPopup->ShowPopup();
4751 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4753 __pGeolocationConfirmPopup.release();
4756 case USER_CONFIRM_NOTIFICATION:
4758 __pNotificationConfirmPopup.reset();
4760 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4762 r = __pNotificationConfirmPopup->ShowPopup();
4763 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4765 __pNotificationConfirmPopup.release();
4768 case USER_SCRIPT_ALERT:
4770 __pScriptAlertConfirmPopup.reset();
4772 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4774 r = __pScriptAlertConfirmPopup->ShowPopup();
4775 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4777 __pScriptAlertConfirmPopup.release();
4790 _WebImpl::GetParentFormCore(_Control* pControlCore)
4793 _Form* pFormCore = null;
4795 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4796 if (!pParentControlCore)
4801 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4807 return GetParentFormCore(pParentControlCore);
4812 _WebImpl::OnFocusGained(const _ControlImpl& source)
4819 _WebImpl::OnFocusLost(const _ControlImpl& source)
4821 if(IsKeypadVisible() == true)
4823 SetKeypadOpened(true);
4825 SetKeypadVisibleState(false);
4828 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4835 _WebImpl::HasValidNativeNode(void) const
4837 if (__pWebCore && __pWebCore->GetWebNativeNode())
4847 _WebImpl::OnPreAttachedToMainTree(void)
4849 result r = E_SUCCESS;
4851 r = __pWebCore->InitializeWebNativeNode();
4852 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4854 r = InitializeSetting();
4855 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4857 r = _ContainerImpl::OnPreAttachedToMainTree();
4858 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4865 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4867 _ContainerImpl::OnChangeLayout(orientation);
4869 __isOrientationChanged = true;
4871 if (__pColorPicker.get())
4873 __pColorPicker->ChangeLayout(orientation);
4876 HideFormDataWindow();
4878 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4879 _WebNotification* pWebNotification = null;
4881 while (pEnum->MoveNext() == E_SUCCESS)
4883 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4884 pWebNotification->OnChangeLayout();
4890 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4892 if (IsVisible() == true)
4894 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4898 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4904 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4906 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
4910 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4911 __pCertConfirmPopup.reset();
4913 case ID_PROMPT_POPUP_CLOSE:
4914 __pPromptPopup.reset();
4916 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
4917 __pUserMediaConfirmPopup.reset();
4919 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
4920 __pGeolocationConfirmPopup.reset();
4922 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
4923 __pNotificationConfirmPopup.reset();
4925 case ID_USER_SCRIPT_ALERT_CLOSE:
4926 __pScriptAlertConfirmPopup.reset();
4935 _WebImpl::GetDownloadHandler(void) const
4937 return __pWebDownloadHandler.get();
4942 _WebImpl::HideColorPicker(void)
4944 __pColorPicker.reset();
4951 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4953 result r = E_SUCCESS;
4955 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4956 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4958 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4960 r = pColorHadler->Construct(colorVal, this);
4961 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4963 __pColorPicker = std::move(pColorHadler);
4965 r = __pColorPicker->ShowPopup();
4966 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4968 color = __pColorPicker->GetColor();
4973 __pColorPicker.reset();
4980 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4982 result r = E_SUCCESS;
4984 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4985 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4987 r = pInputPicker->Construct(String(inputValue), inputType, this);
4988 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4990 __pDatePicker = std::move(pInputPicker);
4992 r = __pDatePicker->ShowPopup();
4993 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4995 dateStr = __pDatePicker->GetDate();
4998 __pDatePicker.reset();
5005 _WebImpl::GetInstance(Web* pWeb)
5007 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5012 _WebImpl::GetInstance(const Web* pWeb)
5014 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5019 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5021 int checkReturn = 0;
5023 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5026 if( checkmime == true)
5028 table = CUSTOM_CONTENT_TABLE_NAME;
5032 table = CUSTOM_PROTOCOL_TABLE_NAME;
5035 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5036 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5037 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5039 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5041 result r = db.Construct(handlerPath, "r+", null);
5042 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5044 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"'"));
5045 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5049 r = pEnum->MoveNext();
5050 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5051 r = pEnum->GetIntAt(0, checkReturn);
5052 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5064 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5068 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5071 if( checkmime == true)
5073 table = CUSTOM_CONTENT_TABLE_NAME;
5077 table = CUSTOM_PROTOCOL_TABLE_NAME;
5080 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5081 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5082 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5084 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5086 result r = db.Construct(handlerPath, "r+", null);
5087 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5089 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"'"));
5090 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5094 r = pEnum->MoveNext();
5095 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5096 r = pEnum->GetIntAt(0, checkId);
5097 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5099 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5100 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5102 r = pDeleteStmt->BindInt(0, checkId);
5103 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5105 db.BeginTransaction();
5107 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5109 db.CommitTransaction();
5116 const Tizen::Base::String
5117 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5119 if (originUri == L"" || currentUri == L"")
5124 result r = E_SUCCESS;
5127 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5128 String originReplace(originUri);
5129 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5133 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5134 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5136 r = currentUri.SubString(0, found + 1, baseUri);
5137 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5139 r = db.Construct(handlerPath, "r+", null);
5140 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5142 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5143 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5147 while (pEnum->MoveNext() == E_SUCCESS)
5152 String originScheme;
5154 r = pEnum->GetStringAt(0, protocol);
5155 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5157 r = pEnum->GetStringAt(1, queryUrl);
5158 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5160 r = pEnum->GetIntAt(2, allow);
5161 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5168 String protocolScheme(protocol + L":");
5170 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5171 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5173 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5175 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5177 r = originReplace.Replace(originScheme, "");
5178 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5180 queryUrl.Replace("%s", originReplace, 0);
5181 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5193 const Tizen::Base::String
5194 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5196 if (originUri == L"" || currentUri == L"" || mime == L"")
5201 result r = E_SUCCESS;
5204 String originUrlStr = originUri;
5205 const String replaceStr = L"%s";
5207 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5208 String table(CUSTOM_CONTENT_TABLE_NAME);
5212 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5213 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5215 r = currentUri.SubString(0, found + 1, baseUri);
5216 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5218 r = db.Construct(handlerPath, "r+", null);
5219 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5221 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5225 r = pEnum->MoveNext();
5226 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5227 r = pEnum->GetIntAt(0, allow);
5228 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5229 r = pEnum->GetStringAt(1, contentUrl);
5230 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5238 if (contentUrl != L"")
5240 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5241 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5253 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5255 __pFormDataList = pFormDataList;
5260 _WebImpl::IsFormDataWindowVisible(void) const
5262 return __isFormDataVisible;
5267 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5269 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5271 if (__isFormDataVisible)
5273 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5274 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5278 __pFormDataWindow.reset();
5280 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5281 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5283 result r = pFormDataWindow->Construct(rect, this, pWebView);
5284 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5286 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5287 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5289 r = pFormDataWindow->LaunchFormDataWindow();
5290 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5292 __pFormDataWindow = std::move(pFormDataWindow);
5293 __isFormDataVisible = true;
5301 _WebImpl::HideFormDataWindow(bool delWindow)
5305 __pFormDataWindow.reset();
5308 __isFormDataVisible = false;
5313 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5315 __webNotificationList.Remove(*pWebNotification);
5320 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5322 __webNotificationList.Add(pWebNotification);
5327 _WebImpl::OnDownloadCompleted(RequestId reqId, const String &path)
5329 _ContentManagerImpl::ScanFile(path);
5333 }}} // Tizen::Web::Controls