2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_WebImpl.cpp
20 * @brief The file contains the definition of _WebImpl class.
22 * The file contains the definition of _WebImpl class.
24 #include <Ecore_IMF_Evas.h>
25 #include <Ecore_Evas.h>
26 #include <elm_config.h>
29 #include <ewk_popup_menu_item.h>
30 #include <libsoup/soup-status.h>
32 #include <FAppAppControl.h>
33 #include <FAppIAppControlListener.h>
34 #include <FBaseColAllElementsDeleter.h>
35 #include <FBaseColHashMapT.h>
36 #include <FBaseRtMutex.h>
37 #include <FBaseRtMutexGuard.h>
38 #include <FBaseSysLog.h>
39 #include <FBaseUtilUri.h>
40 #include <FCntDownloadRequest.h>
41 #include <FGrpColor.h>
42 #include <FGrpPoint.h>
43 #include <FGrpRectangle.h>
44 #include <FIoDbEnumerator.h>
45 #include <FIoDbStatement.h>
47 #include <FMediaImage.h>
48 #include <FMediaImageTypes.h>
49 #include <FNetHttpHttpHeader.h>
50 #include <FSysVibrator.h>
51 #include <FUiControl.h>
52 #include <FUiCtrlKeypad.h>
53 #include <FWebCtrlHitElementResult.h>
54 #include <FWebCtrlITextSearchListener.h>
55 #include <FWebCtrlIWebDownloadListener.h>
56 #include <FWebCtrlIWebUiEventListener.h>
57 #include <FWebCtrlIWebUiEventListenerF.h>
58 #include <FWebCtrlIWebKeypadEventListener.h>
59 #include <FWebCtrlIJavaScriptBridge.h>
60 #include <FWebCtrlPageNavigationList.h>
61 #include <FWebCtrlAuthenticationChallenge.h>
62 #include <FWebCtrlWeb.h>
63 #include <FWebCtrlWebSetting.h>
64 #include <FWebHistoryItem.h>
65 #include <FWebJsonJsonObject.h>
66 #include <FWebJsonJsonParser.h>
67 #include <FWebJsonJsonString.h>
68 #include <FApp_AppControlImpl.h>
69 #include <FApp_AppControlManager.h>
70 #include <FApp_AppInfo.h>
71 #include <FApp_AppManagerImpl.h>
72 #include <FBase_StringConverter.h>
73 #include <FCnt_DownloadManagerImpl.h>
74 #include <FGrp_CoordinateSystem.h>
75 #include <FGrp_Screen.h>
76 #include <FIo_DatabaseImpl.h>
77 #include <FIo_NormalFile.h>
78 #include <FSys_VibratorImpl.h>
79 #include <FUi_Control.h>
80 #include <FUi_CoordinateSystemUtils.h>
81 #include <FUi_EcoreEvasMgr.h>
82 #include <FUi_EcoreEvas.h>
83 #include <FUi_ResourceSizeInfo.h>
84 #include <FUi_Window.h>
85 #include <FUiAnim_EflNode.h>
86 #include <FUiAnim_VisualElement.h>
87 #include <FUiCtrl_FooterImpl.h>
88 #include <FUiCtrl_Form.h>
89 #include "FWeb_HistoryItemImpl.h"
90 #include "FWebCtrl_AppControlListener.h"
91 #include "FWebCtrl_AuthConfirmPopup.h"
92 #include "FWebCtrl_AuthenticationChallengeImpl.h"
93 #include "FWebCtrl_EflWebkit.h"
94 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
95 #include "FWebCtrl_HitElementResultImpl.h"
96 #include "FWebCtrl_InputPickerPopup.h"
97 #include "FWebCtrl_WebNotification.h"
98 #include "FWebCtrl_PageNavigationListImpl.h"
99 #include "FWebCtrl_PromptPopup.h"
100 #include "FWebCtrl_SelectBox.h"
101 #include "FWebCtrl_Utility.h"
102 #include "FWebCtrl_Web.h"
103 #include "FWebCtrl_WebDataHandler.h"
104 #include "FWebCtrl_WebEvent.h"
105 #include "FWebCtrl_WebEventArg.h"
106 #include "FWebCtrl_WebImpl.h"
107 #include "FWebCtrl_WebPresenter.h"
108 #include "FWebCtrl_WebSettingImpl.h"
111 using namespace Tizen::App;
112 using namespace Tizen::Base;
113 using namespace Tizen::Base::Collection;
114 using namespace Tizen::Base::Runtime;
115 using namespace Tizen::Base::Utility;
116 using namespace Tizen::Content;
117 using namespace Tizen::Graphics;
118 using namespace Tizen::Io;
119 using namespace Tizen::Media;
120 using namespace Tizen::Net::Http;
121 using namespace Tizen::System;
122 using namespace Tizen::Ui;
123 using namespace Tizen::Ui::Animations;
124 using namespace Tizen::Ui::Controls;
125 using namespace Tizen::Web::Json;
128 namespace Tizen { namespace Web { namespace Controls
132 static const char WEB_CTRL[] = "webcontrol";
133 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
136 static const float MIN_ZOOM_LEVEL = 0.3;
137 static const float MAX_ZOOM_LEVEL = 2;
140 static const int REDIRECTION_HEADER_GROUP = 300;
143 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
146 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
147 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
148 static const int DEFAULT_LIST_ITEM_COUNT = 4;
152 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
154 result r = E_SUCCESS;
156 String key(reinterpret_cast< const char* >(pKey));
157 String value(reinterpret_cast< char* >(pValue));
159 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
161 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
162 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
169 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
171 result r = E_SUCCESS;
173 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
174 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
175 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
177 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
179 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
180 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
182 pAttrValue.release();
189 FreeCharArray(void* pData)
191 delete[] reinterpret_cast<char*>(pData);
196 ConvertErrorCode(int error)
198 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
202 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
204 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
206 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
208 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
210 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
212 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
214 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
216 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
218 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
220 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
222 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
224 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
226 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
228 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
229 errorCode = WEB_NO_CONNECTION;
232 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
234 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
235 errorCode = WEB_BAD_URL;
238 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
239 errorCode = WEB_FILE_ACCESS_FAILED;
242 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
243 errorCode = WEB_REQUEST_TIMEOUT;
246 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
247 errorCode = WEB_MIME_NOT_SUPPORTED;
250 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
251 errorCode = WEB_OUT_OF_MEMORY;
254 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
255 errorCode = WEB_REQUEST_MAX_EXCEEDED;
258 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
260 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
262 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
264 case EWK_ERROR_NETWORK_STATUS_OK:
266 case EWK_ERROR_NETWORK_STATUS_CREATED:
268 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
270 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
272 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
274 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
276 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
278 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
280 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
282 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
284 case EWK_ERROR_NETWORK_STATUS_FOUND:
286 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
288 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
290 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
292 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
294 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
295 errorCode = WEB_HTTP_RESPONSE;
298 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
299 errorCode = WEB_INVALID_CERTIFICATE;
303 errorCode = WEB_ERROR_UNKNOWN;
312 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
314 result r = E_SUCCESS;
316 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
317 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
318 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
319 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
321 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
322 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
323 pErrorCode.release();
325 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
326 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
327 pErrorDescription.release();
329 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
330 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
338 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
340 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
342 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
343 String msg(pMessage);
345 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
346 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
350 ewk_view_javascript_alert_reply(pView);
356 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
358 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
360 result r = E_SUCCESS;
361 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
362 String msg(pMessage);
364 MessageBox messageBox;
365 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
366 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
370 messageBox.SetOwner(&pImpl->GetPublic());
372 r = messageBox.ShowAndWait(modalResult);
373 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
375 if (modalResult == MSGBOX_RESULT_OK)
377 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
381 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
389 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
391 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
393 result r = E_SUCCESS;
394 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
395 String msg(pMessage);
396 String defVal(pDefaultValue);
398 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
399 SysTryCatch(NID_WEB_CTRL, pPromptPopup.get(), , E_OUT_OF_MEMORY, "Memory allocation failed.");
401 r = pPromptPopup->Construct(msg, defVal, pView);
402 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
404 pPromptPopup->SetOwner(&pImpl->GetPublic());
406 r = pPromptPopup->ShowPopup();
407 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
409 pPromptPopup.release();
414 ewk_view_javascript_prompt_reply(pView, null);
421 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
423 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
424 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
425 SysAssertf(pImpl && pPolicy, "Failed to request");
427 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
429 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
431 if (pImpl->IsCertificateRequested())
433 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
437 result r = E_SUCCESS;
439 std::unique_ptr<DbEnumerator> pEnum;
441 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
442 String table(CERTIFICATE_TABLE_NAME);
445 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
447 r = db.Construct(certificatePath, "r", null);
448 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
450 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
453 r = pEnum->MoveNext();
454 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
457 r = pEnum->GetIntAt(0, allow);
458 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
460 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
462 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
463 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
467 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
468 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
471 pImpl->SetCertificateRequested(true);
474 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
475 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
477 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
478 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
487 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
488 pImpl->SetCertificateConfirmed(false);
489 pImpl->SetCertificateRequested(true);
494 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
496 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
497 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
498 SysAssertf(pImpl && pChallenge, "Failed to request");
500 result r = E_SUCCESS;
502 r = pImpl->HttpAuthenticationRequested(pChallenge);
503 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
507 ewk_auth_challenge_credential_cancel(pChallenge);
508 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
513 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
515 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
516 SysAssertf(pImpl , "Failed to request");
518 if (pImpl->GetLoadingListener())
520 result r = E_SUCCESS;
522 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
523 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
525 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
526 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
532 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
534 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
535 SysAssertf(pImpl , "Failed to request");
537 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
539 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
540 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
542 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
543 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
550 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
552 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
553 SysAssertf(pImpl , "Failed to request");
555 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
557 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
558 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
560 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
561 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
568 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
570 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
571 SysAssertf(pImpl , "Failed to request");
573 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
575 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
576 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
578 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
579 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
585 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
587 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
588 SysAssertf(pImpl , "Failed to request");
590 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
592 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
593 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
595 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
596 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
603 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
605 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
606 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
607 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
609 if (pImpl->GetSetting().IsGeolocationEnabled())
611 result r = E_SUCCESS;
613 std::unique_ptr<DbEnumerator> pEnum;
615 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
616 String table(GEOLOCATION_TABLE_NAME);
619 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
620 String origin = _Utility::CreateOrigin(pSecurityOrigin);
622 r = db.Construct(geolocationPath, "r", null);
623 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
625 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
628 r = pEnum->MoveNext();
629 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
632 r = pEnum->GetIntAt(0, permission);
633 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
635 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
637 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
641 ewk_geolocation_permission_request_suspend(pPermissionRequest);
643 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
644 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
651 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
656 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
658 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
659 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
660 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
662 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
663 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
667 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
672 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
674 result r = E_SUCCESS;
675 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
677 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
678 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
680 ewk_notification_permission_request_suspend(pPermissionRequest);
682 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
683 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
687 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
692 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
694 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
695 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
696 SysAssertf(pImpl && pNotification, "Failed to request");
698 result r = E_SUCCESS;
699 Ewk_Context* pContext = ewk_view_context_get(pView);
700 SysAssertf(pContext, "Failed to get webkit instance.");
701 uint64_t notificationId = ewk_notification_id_get(pNotification);
703 //ewk_notification_security_origin_get(pNotification)
705 const char* text = ewk_notification_body_get(pNotification);
706 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
708 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
709 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
711 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
712 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
714 pNotificationWindow->SetText(String(text));
715 pNotificationWindow->LaunchNotification();
716 pNotificationWindow.release();
718 ewk_notification_showed(pContext, notificationId);
723 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
725 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
726 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
727 SysAssertf(pImpl && pNotificationID, "Failed to request");
729 //ToDo : Where is ewk API for cancel operation?
734 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
736 result r = E_SUCCESS;
737 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
738 SysAssertf(pImpl, "Failed to request");
740 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
741 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
746 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
748 int checkHandler = 0;
749 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
750 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
751 SysAssertf(pImpl && pHandlerData, "Failed to request");
753 checkHandler = pImpl->SearchHandler(pHandlerData, false);
754 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
755 switch (checkHandler)
760 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
763 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
766 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
774 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
776 result r = E_SUCCESS;
777 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
778 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
779 SysAssertf(pImpl && pHandlerData, "Failed to request");
781 r = pImpl->UnregistrationHandler(pHandlerData, false);
782 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
787 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
789 result r = E_SUCCESS;
790 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
791 SysAssertf(pImpl, "Failed to request");
793 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
794 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
799 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
801 int checkHandler = 0;
802 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
803 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
804 SysAssertf(pImpl && pHandlerData, "Failed to request");
806 checkHandler = pImpl->SearchHandler(pHandlerData, true);
807 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
809 switch (checkHandler)
814 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
817 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
820 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
829 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
831 result r = E_SUCCESS;
832 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
833 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
834 SysAssertf(pImpl && pHandlerData, "Failed to request");
836 r = pImpl->UnregistrationHandler(pHandlerData, true);
837 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
842 OnVibrationRequested(uint64_t duration, void* pUserData)
844 result r = E_SUCCESS;
846 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
847 SysAssertf(pImpl, "Failed to request");
849 r = pImpl->VibrationRequested(duration);
850 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
855 OnVibrationCanceled(void* pUserData)
857 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
858 SysAssertf(pImpl, "Failed to request");
860 pImpl->VibrationCanceled();
865 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
867 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
868 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
869 SysAssertf(pImpl && pPolicy, "Failed to request");
871 String url(ewk_policy_decision_url_get(pPolicy));
872 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
874 if (url == L"about:blank")
876 ewk_policy_decision_use(pPolicy);
880 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
881 && !pImpl->IsRedirectRequested())
883 pImpl->SetCertificateRequested(false);
885 if (pImpl->GetTextSearchListener())
887 pImpl->DisableAsyncSearch();
890 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
891 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
893 switch (ewkNavigationType)
895 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
896 navigationType = WEB_NAVIGATION_LINK_CLICKED;
898 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
899 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
901 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
902 navigationType = WEB_NAVIGATION_BACKFORWARD;
904 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
905 navigationType = WEB_NAVIGATION_RELOAD;
907 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
908 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
910 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
911 navigationType = WEB_NAVIGATION_OTHER;
917 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
919 ewk_policy_decision_ignore(pPolicy);
925 String currentUrl(pImpl->GetUrl());
926 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
927 if (redirectUrl != L"")
929 pImpl->LoadUrl(redirectUrl);
930 ewk_policy_decision_ignore(pPolicy);
938 String uriScheme(uri.GetScheme());
939 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
941 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
943 ewk_policy_decision_ignore(pPolicy);
945 if (uriScheme == L"")
950 result r = E_SUCCESS;
952 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
954 if (uriScheme == L"rtsp")
956 eventType = WEB_EVENT_REQUEST_RTSP;
958 else if (uriScheme == L"mailto")
960 eventType = WEB_EVENT_REQUEST_EMAIL;
962 else if (uriScheme == L"tel")
964 eventType = WEB_EVENT_REQUEST_TEL;
966 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
968 eventType = WEB_EVENT_REQUEST_SMS;
970 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
972 eventType = WEB_EVENT_REQUEST_MMS;
975 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
976 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
978 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
979 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
985 ewk_policy_decision_use(pPolicy);
990 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
992 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
993 SysAssertf(pImpl, "Failed to request");
995 if (pImpl->GetLoadingListener())
997 result r = E_SUCCESS;
999 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
1000 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1002 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1003 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1004 pEventArg.release();
1010 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1012 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1013 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1014 SysAssertf(pImpl, "Failed to request");
1016 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1018 if (pImpl->GetLoadingListener())
1020 result r = E_SUCCESS;
1022 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1023 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1024 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1026 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1027 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1028 pPageTitle.release();
1030 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1031 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1032 pEventArg.release();
1038 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1040 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1041 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1042 SysAssertf(pImpl, "Failed to request");
1044 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1046 if (pImpl->GetLoadingListener())
1048 result r = E_SUCCESS;
1050 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1051 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1052 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1054 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1055 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1056 pProgressPercentage.release();
1058 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1059 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1060 pEventArg.release();
1066 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1068 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1069 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1070 SysAssertf(pImpl && pPolicy, "Failed to request");
1072 result r = E_SUCCESS;
1074 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1075 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1076 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1077 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1079 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1081 String url(ewk_policy_decision_url_get(pPolicy));
1084 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1086 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1088 DecisionPolicy policy;
1089 HttpHeader httpHeader;
1091 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1093 pImpl->SetRedirectRequested(true);
1097 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1098 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1100 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1101 pImpl->SetPolicyDecision(policy);
1104 switch (pImpl->GetPolicyDecision())
1106 case WEB_DECISION_CONTINUE:
1108 String currentUrl(pImpl->GetUrl());
1109 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1110 if (redirectUrl != L"")
1112 pImpl->LoadUrl(redirectUrl);
1113 ewk_policy_decision_ignore(pPolicy);
1118 if (pImpl->IsMimeSupported(mime) || mime == L"")
1125 SysLog(NID_WEB_CTRL, "Launch native app to handle the mime");
1127 ewk_policy_decision_ignore(pPolicy);
1129 AppControl* pAppControl = null;
1130 _SelectBox selectBox;
1132 int selectedIndex = 0;
1134 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
1138 appCount = pList->GetCount();
1141 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
1142 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1144 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1145 for (int i = 0; i < appCount; i++)
1147 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
1148 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1150 String text = pAppControl->GetAppName();
1151 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
1153 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1155 r = selectBox.ShowAndWait(selectedIndex);
1156 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1158 if (selectedIndex == 0) //download
1160 RequestId reqId = 0;
1161 DownloadRequest request(pUrl);
1163 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1164 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1166 r = pManagerImpl->Start(request, reqId);
1167 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1169 else if (selectedIndex != -1) // -1 for cancel
1171 String path("path");
1172 String pathVal(pUrl);
1175 r = dataList.Construct();
1176 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1178 r = dataList.Add(path, pathVal);
1179 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1181 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
1182 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1184 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
1185 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1187 r = pAcImpl->Start(null, null, &dataList, null);
1188 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1195 case WEB_DECISION_DOWNLOAD:
1197 ewk_policy_decision_ignore(pPolicy);
1199 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1200 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1202 Ewk_Context* pContext = ewk_view_context_get(pView);
1203 SysAssertf(pContext, "Failed to get webkit instance.");
1205 pDownloadHandler->StartDownload(pUrl);
1209 case WEB_DECISION_IGNORE:
1211 ewk_policy_decision_ignore(pPolicy);
1221 ewk_policy_decision_use(pPolicy);
1226 ewk_policy_decision_ignore(pPolicy);
1231 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1233 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1234 SysAssertf(pImpl, "Failed to request");
1236 if (pImpl->IsRedirectRequested())
1238 pImpl->SetRedirectRequested(false);
1241 if (pImpl->IsLoadingErrorOccurred())
1243 pImpl->SetLoadingErrorOccurred(false);
1244 evas_object_smart_callback_call(pView, "load,finished", NULL);
1250 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1252 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1253 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1254 SysAssertf(pImpl && pErrorData, "Failed to request");
1256 int code = ewk_error_code_get(pErrorData);
1257 const char* pDescription = ewk_error_description_get(pErrorData);
1259 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1261 pImpl->SetLoadingErrorOccurred(true);
1264 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1266 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1269 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1270 evas_object_smart_callback_call(pView, "load,stop", NULL);
1274 if (pImpl->GetLoadingListener())
1276 result r = E_SUCCESS;
1278 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1279 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1287 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1289 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1290 SysAssertf(pImpl, "Failed to request");
1292 if (pImpl->GetLoadingListener())
1294 result r = E_SUCCESS;
1296 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1297 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1299 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1300 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1301 pEventArg.release();
1308 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1310 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1311 SysAssertf(pImpl, "Failed to request");
1313 if (pImpl->GetLoadingListener())
1315 result r = E_SUCCESS;
1317 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1318 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1320 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1321 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1322 pEventArg.release();
1329 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1331 evas_object_focus_set(pView, EINA_FALSE);
1336 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1338 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1339 SysAssertf(pImpl, "Failed to request");
1341 if (pImpl->GetLoadingListener())
1343 result r = E_SUCCESS;
1345 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1346 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1348 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1349 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1350 pEventArg.release();
1357 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1359 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1360 SysAssertf(pUrl && pImpl != null, "Failed to request");
1362 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1367 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1369 result r = E_SUCCESS;
1371 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1372 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1374 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1375 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1376 pEventArg.release();
1383 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1385 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1386 SysAssertf(pImpl, "Failed to request");
1388 if (pImpl->GetUiEventListener())
1390 result r = E_SUCCESS;
1392 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1393 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1395 if (pImpl->GetUiEventListenerF())
1397 result r = E_SUCCESS;
1399 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1400 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1406 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1408 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1409 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1410 SysAssertf(pParentImpl && pChildView, "Failed to request");
1412 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1413 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1414 if (pUserUiListener)
1416 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1419 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1420 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1422 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1423 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1426 if (pUserUiListenerF)
1428 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1431 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1432 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1434 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1435 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1442 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1444 result r = E_SUCCESS;
1446 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1447 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1449 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1450 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1451 pEventArg.release();
1458 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1460 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1461 SysAssertf(pChildImpl, "Failed to request");
1463 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1464 if (pParentImpl == null)
1469 if (pParentImpl->GetUiEventListener())
1471 result r = E_SUCCESS;
1473 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1474 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1476 if (pParentImpl->GetUiEventListenerF())
1478 result r = E_SUCCESS;
1480 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1481 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1487 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1489 result r = E_SUCCESS;
1491 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1492 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1493 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1495 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1496 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1497 pPreventTrigger.release();
1499 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1500 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1501 pEventArg.release();
1508 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1510 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1511 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1512 SysAssertf(pImpl && pTrigger, "Failed to request");
1514 if (pImpl->GetUiEventListener())
1516 result r = E_SUCCESS;
1518 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1519 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1521 if (pImpl->GetUiEventListenerF())
1523 result r = E_SUCCESS;
1525 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1526 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1532 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1534 result r = E_SUCCESS;
1536 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1537 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1538 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1540 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1542 if ((endPoint->x != 0) && (endPoint->y != 0))
1544 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1545 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1547 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1548 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1549 startPoint.release();
1551 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1552 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1555 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1556 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1557 pEventArg.release();
1565 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1567 result r = E_SUCCESS;
1569 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1570 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1572 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1574 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1576 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1578 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1579 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1581 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1582 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1583 startPoint.release();
1585 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1586 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1589 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1590 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1591 pEventArg.release();
1599 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1601 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1602 SysAssertf(pImpl, "Failed to request");
1604 if (pImpl->GetUiEventListener())
1606 result r = E_SUCCESS;
1608 r = FireWebPageBlockSelectedEvent(pImpl);
1609 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1611 if (pImpl->GetUiEventListenerF())
1613 result r = E_SUCCESS;
1615 r = FireWebPageBlockSelectedEventF(pImpl);
1616 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1622 OnWebPageBlockSelectedByOrientation(void* pUserData, Evas_Object* pView, void* pEventInfo)
1624 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1625 SysAssertf(pImpl, "Failed to request");
1627 if (!pImpl->IsOrientationChanged())
1632 pImpl->SetOrientationChanged(false);
1634 int orientation = 0;
1635 _ControlRotation rotation = _ControlManager::GetInstance()->GetOrientationStatus();
1638 case _CONTROL_ROTATION_0:
1641 case _CONTROL_ROTATION_90:
1644 case _CONTROL_ROTATION_180:
1647 case _CONTROL_ROTATION_270:
1651 ewk_view_orientation_send(pView, orientation);
1653 OnWebPageBlockSelected(pUserData, pView, pEventInfo);
1658 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1660 String isMultipleSelection(L"single");
1661 result r = E_SUCCESS;
1664 String mode(L"selectionType");
1665 String type(L"type");
1666 _AppControlImpl* pMediaAppControlImpl = null;
1669 String fileType = L"all";
1673 isMultipleSelection.Append(L"multiple");
1676 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1677 SysTryReturn(NID_WEB_CTRL, pMediaAppControl.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1679 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1680 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1682 pMediaListener->Construct(pView, pMediaAppControl.get());
1684 itemCount = eina_list_count(pAcceptTypes);
1688 String item((char*)eina_list_nth(pAcceptTypes, 0));
1689 if (item.StartsWith("image/",0))
1691 fileType = L"image";
1693 else if (item.StartsWith("audio/",0))
1695 fileType = L"audio";
1697 else if (item.StartsWith("video/",0))
1699 fileType = L"video";
1703 r = dataList.Construct();
1704 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1706 r = dataList.Add(mode, isMultipleSelection);
1707 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1709 r = dataList.Add(type, fileType);
1710 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1712 pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl.get());
1713 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1714 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1716 pMediaListener.release();
1717 pMediaAppControl.release();
1722 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1728 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1730 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1731 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1732 SysAssertf(pImpl && pJsonText, "Failed to request");
1734 result r = E_SUCCESS;
1736 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1738 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1739 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1741 r = pEventArg->Construct(pJsonText);
1742 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1744 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1745 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1746 pEventArg.release();
1751 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1753 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1754 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1755 SysAssertf(pImpl && pEinaRect, "Failed to request");
1757 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1759 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1760 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1762 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1764 if (rect.height == 0)
1769 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1772 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1774 pImpl->SetFooterVisibleState(true);
1775 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1778 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1781 if (pImpl->GetWebKeypadEventListener())
1783 if (pImpl->IsKeypadVisible() == true)
1785 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1787 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1792 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1795 pImpl->SetKeypadVisibleState(true);
1796 pImpl->SetPreviousKeypadBounds(rect);
1800 result r = pImpl->SetFullScreenKeypad();
1801 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1807 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1809 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1810 SysAssertf(pImpl, "Failed to request");
1812 if (pImpl->GetWebKeypadEventListener())
1814 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1820 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1822 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1823 SysAssertf(pImpl, "Failed to request");
1825 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1828 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1830 pImpl->SetFooterVisibleState(false);
1831 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1834 pFormCore->DeflateClientRectHeight(0);
1837 if (pImpl->GetWebKeypadEventListener())
1839 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1842 pImpl->SetKeypadVisibleState(false);
1847 OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info)
1849 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1850 SysAssertf(pImpl, "Failed to request");
1852 if (pImpl->IsKeypadOpened() == true)
1854 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1855 SysAssertf(pWebCore, "Failed to get Web core object");
1857 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1859 pImpl->SetKeypadOpened(false);
1865 OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo)
1867 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1868 SysAssertf(pImpl, "Failed to request");
1870 if (pImpl->IsKeypadOpened() == true)
1872 pImpl->SetKeypadOpened(false);
1878 OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha)
1880 SysAssertf(pSmartData, "invalid smartdata");
1881 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1882 SysAssertf(pWebImpl, "Failed to get Impl");
1884 result r = E_SUCCESS;
1886 if (pWebImpl->GetColorpicker())
1893 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1894 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1896 byte r1, g1, b1, a1;
1897 color.GetColorComponents(r1, g1, b1, a1);
1898 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1905 OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData)
1907 SysAssertf(pSmartData, "invalid smartdata");
1909 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1910 SysAssertf(pWebImpl, "Failed to get Impl");
1912 return pWebImpl->HideColorPicker();
1917 OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1919 SysAssertf(pSmartData, "Failed to request");
1920 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1921 SysAssertf(pWebImpl, "Failed to get Impl");
1923 result r = E_SUCCESS;
1925 if (pWebImpl->GetDatepicker())
1927 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1934 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1935 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1937 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1938 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1940 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1947 OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1949 SysAssertf(pSmartData, "Failed to request");
1951 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1952 SysAssertf(pWebImpl, "Failed to get Impl");
1954 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1955 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1962 OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData)
1964 SysAssertf(pSmartData, "invalid smartdata");
1966 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1967 SysAssertf(pWebImpl, "Failed to get Impl");
1969 result r = pWebImpl->ClearSelectBoxPopup();
1970 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1977 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1979 SysAssertf(pSmartData, "invalid smartdata");
1981 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1982 SysAssertf(pWebImpl, "Failed to get Impl");
1984 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1985 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1992 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1994 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1995 SysAssertf(pPresenter && !pError, "Failed to request");
1997 bool ret = EINA_TRUE;
2001 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2003 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2007 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2016 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2018 pPresenter->EndAsyncProcess(ret);
2023 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2025 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2026 SysAssertf(pPresenter, "Failed to request");
2028 String result(pResult);
2029 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2031 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2032 if (pImpl && pImpl->IsPresenterAlived(pPresenter))
2034 pPresenter->EndAsyncProcess(result);
2040 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2042 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2043 SysAssertf(pImpl, "Failed to request");
2045 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2046 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2048 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2052 pWebPresenter->EndAsyncProcess(*pTotalCount);
2056 if (pImpl->GetTextSearchListener())
2058 result r = E_SUCCESS;
2062 if (*pTotalCount > 0)
2064 ordinal = pImpl->GetAsyncSearchOrdinal();
2065 pImpl->SetAsyncSearchResult(*pTotalCount);
2068 if (pImpl->GetPendingAsyncSearchCount() > 0)
2073 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2074 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2075 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2076 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2078 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2079 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2082 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2083 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2086 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2087 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2088 pEventArg.release();
2094 class _JsBridgeHashCodeProvider
2095 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2098 _JsBridgeHashCodeProvider(){}
2099 virtual ~_JsBridgeHashCodeProvider(void) {}
2102 int GetHashCode(const Tizen::Base::String& obj) const
2104 return obj.GetHashCode();
2110 //Comparer implementation
2111 class _JsBridgeComparer
2112 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2115 _JsBridgeComparer(){}
2116 virtual ~_JsBridgeComparer(void) {}
2119 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2136 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2137 : _ContainerImpl(pWeb, pCore)
2138 , __isFooterVisible(false)
2139 , __isKeypadVisible(false)
2140 , __isKeypadOpened(false)
2141 , __isLoadingErrorOccurred(false)
2142 , __isRedirectRequested(false)
2143 , __isCertificateRequested(false)
2144 , __isCertificateConfirmed(false)
2145 , __isOrientationChanged(false)
2146 , __keypadBounds(0, 0, 0, 0)
2148 , __pUserLoadingListener(null)
2149 , __pUserUiListener(null)
2150 , __pUserUiListenerF(null)
2151 , __pUserKeypadEventListener(null)
2152 , __pTextSearchListener(null)
2154 , __pJsBridgeList(null)
2155 , __pJsProvider(null)
2156 , __pJsComparer(null)
2157 , __pWebDownloadHandler(null)
2159 , __pAuthChallenge(null)
2160 , __pAuthPopup(null)
2161 , __pUserConfirmPopup(null)
2162 , __pCertConfirmPopup(null)
2163 , __pSelectBox(null)
2164 , __pDatePicker(null)
2165 , __pColorPicker(null)
2167 , __policy(WEB_DECISION_CONTINUE)
2168 , __defaultUserAgent(L"")
2170 __textSearch.__searchAll = false;
2171 __textSearch.__searchForward = true;
2172 __textSearch.__caseSensitive = false;
2173 __textSearch.__pending = 0;
2174 __textSearch.__currentIndex = 1;
2175 __textSearch.__totalCount = -1;
2176 __textSearch.__text = L"";
2180 _WebImpl::~_WebImpl()
2182 RemoveEventListenerCallback();
2183 ClearCertificateDb();
2188 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2190 result r = E_SUCCESS;
2192 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2193 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2195 _Web* pCore = _Web::CreateWebN();
2196 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2198 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2200 r = CheckConstruction(pCore, pImpl);
2201 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2203 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2204 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2206 r = pImpl->Construct();
2207 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2219 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2221 result r = E_SUCCESS;
2223 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2224 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2226 _Web* pCore = _Web::CreateWebN();
2227 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2229 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2231 r = CheckConstruction(pCore, pImpl);
2232 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2234 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2235 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2237 r = pImpl->Construct();
2238 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2250 _WebImpl::Construct(void)
2252 result r = E_SUCCESS;
2254 r = __mutex.Create();
2255 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2257 r = __textSearch.__searchQueue.Construct();
2258 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2260 r = __callbackList.Construct();
2261 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2263 r = InitJsBridgeList();
2264 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2267 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2269 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2270 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2277 _WebImpl::InitializeSetting(void)
2279 result r = E_SUCCESS;
2281 WebSetting* pWebSetting = __pWebCore->GetSetting();
2282 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2284 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2285 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2286 SetZoomLevel(pWebSettingImpl->GetZoomLevel());
2288 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2290 r = SetSetting(*pWebSetting);
2291 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2293 SetEventListenerCallback();
2300 _WebImpl::IsLayoutable(void) const
2307 _WebImpl::InitWebEvent(void)
2309 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2310 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2312 return __pWebEvent->Construct(*this);
2317 _WebImpl::GetWebEvent(void) const
2319 return __pWebEvent.get();
2324 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2326 Eina_Hash* pHttpHeader = null;
2328 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2329 if (pFieldNameList.get())
2331 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2332 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2334 int count = pFieldNameList->GetCount();
2336 for (int i = 0; i < count; i++)
2338 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2339 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2341 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2342 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2344 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2345 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2347 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2349 Eina_Bool ret = false;
2351 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2352 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2354 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2355 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2357 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2358 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2365 eina_hash_free(pHttpHeader);
2372 _WebImpl::LoadUrl(const String& url) const
2374 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2375 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2377 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2384 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2386 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2387 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2389 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2391 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2393 eina_hash_free(pHttpHeader);
2400 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2402 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2403 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2405 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2407 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2409 eina_hash_free(pHttpHeader);
2416 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2418 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2420 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2421 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2422 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2423 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2425 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2432 _WebImpl::Pause(void)
2434 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2439 _WebImpl::Resume(void)
2441 ewk_view_resume(__pWebCore->GetWebNativeNode());
2446 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2448 __pSelectBox.reset();
2450 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2452 result r = E_SUCCESS;
2454 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2455 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2457 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2458 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2460 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2461 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2463 __pSelectBox = std::move(pSelectBox);
2465 __pSelectBox->SetOwner(&GetPublic());
2467 return __pSelectBox->ShowPopup();
2472 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2474 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2476 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2481 _WebImpl::ClearSelectBoxPopup(void)
2483 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2485 __pSelectBox.reset();
2492 _WebImpl::GetDatepicker(void)
2494 _InputPickerPopup* pInputPicker =null;
2497 pInputPicker = __pDatePicker.get();
2499 return pInputPicker;
2504 _WebImpl::GetColorpicker(void)
2506 _InputPickerPopup* pInputPicker =null;
2509 pInputPicker = __pColorPicker.get();
2511 return pInputPicker;
2516 _WebImpl::CanGoBack(void) const
2518 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2523 _WebImpl::CanGoForward(void) const
2525 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2530 _WebImpl::GoBack(void) const
2532 ewk_view_back(__pWebCore->GetWebNativeNode());
2537 _WebImpl::GoForward(void) const
2539 ewk_view_forward(__pWebCore->GetWebNativeNode());
2544 _WebImpl::GetUrl(void) const
2546 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2551 _WebImpl::GetTitle(void) const
2553 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2558 _WebImpl::StopLoading(void) const
2560 ewk_view_stop(__pWebCore->GetWebNativeNode());
2565 _WebImpl::Reload(void) const
2567 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
2572 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2574 if (scriptCode.GetLength() == 0)
2579 result r = E_SUCCESS;
2581 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2582 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2584 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
2585 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2587 r = __callbackList.Add(pPresenter.get());
2588 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2590 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, pPresenter.get());
2592 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2593 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2594 pPresenter->WaitAsyncProcess(*pResult.get());
2596 r = __callbackList.Remove(*pPresenter.get());
2597 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2598 pPresenter.release();
2600 return pResult.release();
2605 _WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
2607 return __callbackList.Contains(*pPresenter);
2612 _WebImpl::SetZoomLevel(float level)
2614 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);
2616 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2623 _WebImpl::GetZoomLevel(void) const
2625 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2629 const PageNavigationList*
2630 _WebImpl::GetBackForwardListN(void) const
2632 result r = E_SUCCESS;
2634 _PageNavigationListImpl* pNavigationListImpl = null;
2635 _HistoryItemImpl* pHistoryItemImpl = null;
2637 std::unique_ptr<PageNavigationList> pNavigationList;
2638 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2641 int forwardCount = 0;
2646 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2647 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2649 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2650 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2652 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2653 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2655 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2656 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2658 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2659 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2661 r = pHistoryList->Construct();
2662 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2664 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2665 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2666 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2668 for (int i = -backCount; i < forwardCount + 1; i++)
2670 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2671 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2673 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2674 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2676 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2677 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2679 url = ewk_history_item_uri_get(pEwkItem);
2680 title = ewk_history_item_title_get(pEwkItem);
2681 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2683 pHistoryItemImpl->SetHistoryItem(url, title);
2685 r = pHistoryList->Add(*pHistoryItem.get());
2686 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2687 pHistoryItem.release();
2690 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2692 ewk_history_free(pEwkHistoryList);
2694 return pNavigationList.release();
2697 ewk_history_free(pEwkHistoryList);
2704 _WebImpl::SearchText(const String& text, bool searchForward)
2706 result r = E_SUCCESS;
2708 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2712 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2715 _WebPresenter presenter;
2716 presenter.InitAsyncProcess();
2718 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2719 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2722 presenter.WaitAsyncProcess(result);
2724 return static_cast < bool >(result);
2729 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2731 result r = E_SUCCESS;
2733 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2737 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2740 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2741 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2748 _WebImpl::SearchNextAsync(bool searchForward)
2750 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2751 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2752 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2754 result r = E_SUCCESS;
2756 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2758 if (!__textSearch.__caseSensitive)
2760 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2765 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2768 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2769 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2776 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2778 MutexGuard lock(__mutex);
2780 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2781 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2786 if (__textSearch.__searchAll)
2788 DisableAsyncSearch();
2790 __textSearch.__searchQueue.Enqueue(this);
2791 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2793 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2794 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2798 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2800 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2804 case SEARCH_ALL_ASYNC:
2805 __textSearch.__searchAll = true;
2806 __textSearch.__text = text;
2807 __textSearch.__searchForward = true;
2808 __textSearch.__caseSensitive = caseSensitive;
2809 __textSearch.__totalCount = -1;
2810 __textSearch.__currentIndex = 1;
2812 __textSearch.__searchQueue.Enqueue(this);
2813 __textSearch.__searchQueue.Enqueue(this);
2815 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2816 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2819 case SEARCH_NEXT_ASYNC:
2820 __textSearch.__searchForward = searchForward;
2822 CalculateAsyncSearchOrdinal();
2824 __textSearch.__searchQueue.Enqueue(this);
2826 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2838 _WebImpl::SetAsyncSearchResult(int totalCount)
2840 __textSearch.__totalCount = totalCount;
2845 _WebImpl::GetSearchPresenter(void)
2847 MutexGuard lock(__mutex);
2849 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2854 _WebImpl::GetPendingAsyncSearchCount(void) const
2856 return __textSearch.__searchQueue.GetCount();
2861 _WebImpl::CalculateAsyncSearchOrdinal(void)
2863 if (__textSearch.__searchForward)
2865 __textSearch.__currentIndex++;
2869 __textSearch.__currentIndex--;
2875 _WebImpl::GetAsyncSearchOrdinal(void) const
2877 return __textSearch.__currentIndex;
2882 _WebImpl::DisableAsyncSearch(void)
2884 __textSearch.__searchAll = false;
2889 _WebImpl::SetSetting(const WebSetting& setting)
2891 if (__pWebCore->GetWebNativeNode())
2893 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2894 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2895 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2897 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2898 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2900 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2902 switch (setting.GetCacheControl())
2904 case WEB_CACHE_VALIDATED:
2905 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2908 case WEB_CACHE_IGNORE:
2909 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2916 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2918 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2922 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2925 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2927 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2929 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2931 if (__defaultUserAgent != setting.GetUserAgent())
2933 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2934 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2936 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2939 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2941 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2943 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2945 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2948 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2950 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2951 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2952 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2953 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2954 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2955 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2956 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2957 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2958 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2959 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2960 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2961 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2962 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2969 _WebImpl::GetSetting(void) const
2971 return *__pWebCore->GetSetting();
2975 const HitElementResult*
2976 _WebImpl::GetElementByPointN(const Point& point) const
2978 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
2982 const HitElementResult*
2983 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2985 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));
2987 result r = E_SUCCESS;
2989 _HitElementResultImpl* pHitElementResultImpl = null;
2991 std::unique_ptr<HitElementResult> pHitElementResult;
2992 std::unique_ptr<Bitmap> pImage;
2993 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2995 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
2997 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2998 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3000 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3001 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3002 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3003 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3004 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3006 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3008 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3009 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3011 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3012 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3014 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3020 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3021 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3022 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3023 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3025 r = buf.Construct(imageLength);
3026 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3028 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3029 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3033 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3034 // webkit support types such as ico and vp8 additionally
3035 if (strcmp(pExtension, "gif") == 0)
3037 format = IMG_FORMAT_GIF;
3039 else if (strcmp(pExtension, "jpg") == 0)
3041 format = IMG_FORMAT_JPG;
3043 else if (strcmp(pExtension, "png") == 0)
3045 format = IMG_FORMAT_PNG;
3047 else if (strcmp(pExtension, "bmp") == 0)
3049 format = IMG_FORMAT_BMP;
3053 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3057 r = image.Construct();
3058 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3060 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3061 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3066 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3067 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3069 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3070 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3072 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3073 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3076 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3078 ewk_hit_test_free(pEwkHitTest);
3080 return pHitElementResult.release();
3083 ewk_hit_test_free(pEwkHitTest);
3090 _WebImpl::IsLoading(void) const
3092 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3094 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3106 _WebImpl::GetTextFromBlock(void) const
3108 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3113 _WebImpl::IsPrivateBrowsingEnabled(void) const
3115 if (__pWebCore->GetWebNativeNode() == null)
3117 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3120 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3121 SysAssertf(pSettings, "Failed to get webkit instance.");
3123 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3128 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3130 if (__pWebCore->GetWebNativeNode() == null)
3132 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3136 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3137 SysAssertf(pSettings, "Failed to get webkit instance.");
3139 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3144 _WebImpl::ClearHistory(void)
3146 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3151 _WebImpl::ClearCache(void)
3153 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3154 SysAssertf(pContext, "Failed to get webkit instance.");
3156 ewk_context_cache_clear(pContext);
3161 _WebImpl::ClearCookie(void)
3163 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3164 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3165 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3167 ewk_cookie_manager_cookies_clear(pCookieManager);
3172 _WebImpl::ClearFormData(void)
3174 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3175 SysAssertf(pContext, "Failed to get webkit instance.");
3177 ewk_context_form_candidate_data_clear(pContext);
3182 _WebImpl::ClearLoginFormData(void)
3184 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3185 SysAssertf(pContext, "Failed to get webkit instance.");
3187 ewk_context_form_password_data_clear(pContext);
3192 _WebImpl::IsCookieEnabled(void) const
3194 if (__pWebCore->GetWebNativeNode() == null)
3196 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3199 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3200 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3201 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3203 _WebPresenter presenter;
3204 presenter.InitAsyncProcess();
3206 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3208 bool result = false;
3209 presenter.WaitAsyncProcess(result);
3216 _WebImpl::SetCookieEnabled(bool enable)
3218 if (__pWebCore->GetWebNativeNode() == null)
3220 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3225 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3226 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3227 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3231 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3235 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3236 ewk_cookie_manager_cookies_clear(pCookieManager);
3242 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3244 result r = E_SUCCESS;
3246 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3247 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3250 String fileExtension = File::GetFileExtension(filePath);
3251 int pathLength = filePath.GetLength();
3254 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3256 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3257 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3258 r = filePath.SubString(0, index + 1, dirPath);
3259 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3261 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3262 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3266 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3268 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3272 Evas_Coord contentsWidth;
3273 Evas_Coord contentsHeight;
3275 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3276 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3284 _WebImpl::IsMimeSupported(const String& mime) const
3286 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3287 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3289 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3294 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3296 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3301 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3303 __pUserUiListener = pUiEventListener;
3308 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3310 __pUserUiListenerF = pUiEventListener;
3315 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3317 __pUserKeypadEventListener = pKeypadEventListener;
3322 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3324 if (__pWebDownloadHandler.get() == null)
3326 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3327 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3330 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3331 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3336 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3338 __pTextSearchListener = pTextSearchListener;
3343 _WebImpl::SetScrollEnabled(bool enable)
3345 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3350 _WebImpl::IsScrollEnabled(void) const
3352 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3357 _WebImpl::InitJsBridgeList(void)
3359 result r = E_SUCCESS;
3361 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3362 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3364 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3365 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3367 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3368 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3370 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3371 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3373 __pJsBridgeList = std::move(pJsBridgeList);
3380 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3382 result r = E_SUCCESS;
3384 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3385 String key(pJsBridge->GetName());
3387 r = __pJsBridgeList->Add(key, pJsBridge);
3388 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3395 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3397 result r = E_SUCCESS;
3399 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3400 String key(pJsBridge->GetName());
3402 r = __pJsBridgeList->Remove(key);
3403 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3410 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3412 result r = E_SUCCESS;
3414 IJsonValue* pJsonValue = null;
3415 IJavaScriptBridge* pJsBridge = null;
3417 String key(L"name");
3419 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3420 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));
3422 r = pJsonObject->GetValue(&key, pJsonValue);
3423 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3425 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3426 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3428 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3429 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3436 _WebImpl::GetLoadingListener(void) const
3438 return __pUserLoadingListener;
3442 IWebUiEventListener*
3443 _WebImpl::GetUiEventListener(void) const
3445 return __pUserUiListener;
3449 IWebUiEventListenerF*
3450 _WebImpl::GetUiEventListenerF(void) const
3452 return __pUserUiListenerF;
3456 IWebKeypadEventListener*
3457 _WebImpl::GetWebKeypadEventListener(void) const
3459 return __pUserKeypadEventListener;
3463 ITextSearchListener*
3464 _WebImpl::GetTextSearchListener(void) const
3466 return __pTextSearchListener;
3471 _WebImpl::SetEventListenerCallback(void) const
3473 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3476 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3477 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3479 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3480 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3482 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3483 SysAssertf(pSmartData, "Failed to request");
3485 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3486 SysAssertf(pSmart, "Failed to request");
3488 pSmart->popup_menu_show = OnSelectBoxRequested;
3489 pSmart->popup_menu_hide = OnSelectBoxClosed;
3490 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3492 pSmart->input_picker_show = OnDatePickerProviderRequested;
3493 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3494 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3496 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3498 // add loading event callbacks for ILoadingListener
3499 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3500 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3502 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3503 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3504 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3505 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3506 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3507 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3508 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3509 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3510 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3512 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3514 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3516 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3517 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3518 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3520 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3521 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3523 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3525 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3526 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3527 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3529 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3531 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3532 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3533 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3535 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3536 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3537 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3539 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3540 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3541 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3543 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3544 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3545 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3546 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3548 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3549 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3551 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3552 evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this);
3554 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3555 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3556 SysAssertf(pContext, "Failed to get webkit instance.");
3557 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3558 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3560 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3561 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3562 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3563 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3565 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3571 _WebImpl::RemoveEventListenerCallback(void) const
3573 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3576 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3577 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3579 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3580 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3582 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3583 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3585 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3586 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3587 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3588 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3589 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3590 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3591 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3592 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3594 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3596 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3598 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3599 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3600 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3602 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3603 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3605 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3607 ewk_view_javascript_alert_callback_set(null, null, null);
3608 ewk_view_javascript_prompt_callback_set(null, null, null);
3609 ewk_view_javascript_confirm_callback_set(null, null, null);
3611 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3613 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3614 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3615 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3617 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3618 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3619 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3620 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3621 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3622 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3624 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3625 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3626 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3628 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3630 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3631 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3633 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3634 evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation);
3636 ewk_view_open_panel_callback_set(null, null, null);
3637 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3638 SysAssertf(pContext, "Failed to get webkit instance.");
3639 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3641 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3642 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3643 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3644 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3646 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3652 _WebImpl::ClearCertificateDb(void)
3654 result r = E_SUCCESS;
3656 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3657 String table(CERTIFICATE_TABLE_NAME);
3660 r = db.Construct(certificatePath, "r+", null);
3661 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3663 db.BeginTransaction();
3665 r = db.ExecuteSql(L"Delete From " + table, true);
3666 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3668 db.CommitTransaction();
3673 db.RollbackTransaction();
3678 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3680 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3685 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3687 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3689 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3690 SysAssertf(pSmartData, "Failed to request");
3692 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3694 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3697 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3699 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3700 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3702 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3704 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3706 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3710 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3711 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3714 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3719 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3726 _WebImpl::ReleaseBlock(void)
3728 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3733 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3735 FloatPoint tempStartPoint;
3736 FloatPoint tempEndPoint;
3738 GetBlockRange(tempStartPoint, tempEndPoint);
3740 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3741 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3746 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3748 Eina_Rectangle leftHandle;
3749 Eina_Rectangle rightHandle;
3751 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3753 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3754 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3755 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3756 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3758 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3760 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3761 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3767 _WebImpl::GetFaviconN(void) const
3769 result r = E_SUCCESS;
3771 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3773 Evas* pEvas = evas_object_evas_get(pView);
3774 Ewk_Context* pContext = ewk_view_context_get(pView);
3775 SysAssertf(pEvas && pContext, "Failed to request");
3777 const char* pUrl = ewk_view_url_get(pView);
3779 Tizen::Graphics::BufferInfo bufferInfo;
3780 Tizen::Base::ByteBuffer byteBuffer;
3782 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3783 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3785 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3791 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3792 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3794 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3796 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3797 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3799 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3800 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3802 return pBitmapImage.release();
3808 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3810 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3815 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3817 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3822 _WebImpl::GetScrollPosition(void) const
3826 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3833 _WebImpl::GetPageSize(void) const
3835 Evas_Coord width = 0;
3836 Evas_Coord height = 0;
3838 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3840 Dimension size(static_cast< int >(width), static_cast< int >(height));
3847 _WebImpl::SetLoadingErrorOccurred(bool arg)
3849 __isLoadingErrorOccurred = arg;
3854 _WebImpl::IsLoadingErrorOccurred(void) const
3856 return __isLoadingErrorOccurred;
3861 _WebImpl::SetRedirectRequested(bool arg)
3863 __isRedirectRequested = arg;
3868 _WebImpl::IsRedirectRequested(void) const
3870 return __isRedirectRequested;
3875 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3882 _WebImpl::GetPolicyDecision(void) const
3889 _WebImpl::SetCertificateRequested(bool arg)
3891 __isCertificateRequested = arg;
3896 _WebImpl::IsCertificateRequested(void) const
3898 return __isCertificateRequested;
3903 _WebImpl::SetCertificateConfirmed(bool arg)
3905 __isCertificateConfirmed = arg;
3910 _WebImpl::IsCertificateConfirmed(void) const
3912 return __isCertificateConfirmed;
3917 _WebImpl::SetOrientationChanged(bool arg)
3919 __isOrientationChanged = arg;
3924 _WebImpl::IsOrientationChanged(void) const
3926 return __isOrientationChanged;
3931 _WebImpl::LaunchAppControl(const IEventArg& arg)
3933 result r = E_SUCCESS;
3935 IEventArg* pArg = const_cast< IEventArg* >(&arg);
3936 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
3937 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
3939 String operationId(L"");
3940 String uriPattern(pWebEventArg->GetEventMessage());
3941 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
3943 switch (pWebEventArg->GetEventType())
3945 case WEB_EVENT_REQUEST_RTSP:
3949 int uriLength = uriPattern.GetLength();
3952 operationId = L"http://tizen.org/appcontrol/operation/view";
3954 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
3955 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3957 r = uriPattern.SubString(index + 1, ext);
3958 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3960 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
3961 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3963 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
3964 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3968 case WEB_EVENT_REQUEST_TEL:
3970 operationId = L"http://tizen.org/appcontrol/operation/dial";
3973 case WEB_EVENT_REQUEST_EMAIL:
3975 case WEB_EVENT_REQUEST_SMS:
3977 case WEB_EVENT_REQUEST_MMS:
3979 operationId = L"http://tizen.org/appcontrol/operation/compose";
3982 case WEB_EVENT_REQUEST_UNKNOWN:
3984 operationId = L"http://tizen.org/appcontrol/operation/view";
3992 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
3993 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4000 _WebImpl::SetFullScreenKeypad(void)
4002 result r = E_SUCCESS;
4004 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4005 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4007 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4008 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4010 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4011 pKeypad->SetText(text);
4013 r = pKeypad->SetShowState(true);
4014 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4016 r = pKeypad->Show();
4017 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4019 pKeypad->AddTextEventListener(*this);
4021 __pKeypad = std::move(pKeypad);
4028 _WebImpl::RemoveFullScreenKeypad(void)
4030 __pKeypad->RemoveTextEventListener(*this);
4037 _WebImpl::IsFooterVisible(void) const
4039 return __isFooterVisible;
4044 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4046 __isFooterVisible = isFooterVisible;
4051 _WebImpl::IsKeypadVisible(void) const
4053 return __isKeypadVisible;
4058 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4060 __isKeypadVisible = isKeypadVisible;
4065 _WebImpl::IsKeypadOpened(void) const
4067 return __isKeypadOpened;
4071 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4073 __isKeypadOpened = isKeypadOpened;
4078 _WebImpl::GetPreviousKeypadBounds(void) const
4080 return __keypadBounds;
4085 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4087 __keypadBounds = bounds;
4092 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4094 RemoveFullScreenKeypad();
4099 _WebImpl::OnTextValueChanged(const Control& source)
4101 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4103 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4105 RemoveFullScreenKeypad();
4110 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4112 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4113 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4115 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4116 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4118 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4119 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4121 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4128 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4130 result r = E_SUCCESS;
4132 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4133 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4135 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4137 ILoadingListener* pLoadingListner = GetLoadingListener();
4138 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4140 switch (pEventArg->GetEventType())
4142 case WEB_EVENT_LOADINGLISTENER_STARTED:
4144 pLoadingListner->OnLoadingStarted();
4148 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4150 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4151 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4153 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4157 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4159 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4160 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4162 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4166 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4168 pLoadingListner->OnLoadingCanceled();
4172 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4174 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4175 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4177 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4178 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4180 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4182 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4186 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4188 pLoadingListner->OnLoadingCompleted();
4192 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4194 pLoadingListner->OnHttpAuthenticationCanceled();
4198 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4200 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4201 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4205 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4221 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4223 result r = E_SUCCESS;
4225 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4226 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4228 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4230 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4231 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4233 switch (pEventArg->GetEventType())
4235 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4237 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4238 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4240 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4244 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4246 pWebDownloadListener->OnWebDataDownloadCompleted();
4250 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4252 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4253 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4255 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4257 pWebDownloadListener->OnWebDownloadFailed(errorType);
4272 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4274 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4275 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4277 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4279 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4281 switch (pEventArg->GetEventType())
4283 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4285 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4287 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4288 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4290 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4291 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4293 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4297 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4299 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4301 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4305 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4307 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4309 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4313 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4315 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4317 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4318 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4320 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4335 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4337 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4338 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4340 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4342 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4344 switch (pEventArg->GetEventType())
4346 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4348 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4350 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4351 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4353 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4354 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4356 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4360 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4362 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4364 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4368 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4370 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4372 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4376 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4378 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4380 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4381 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4383 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4398 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4400 result r = E_SUCCESS;
4402 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4403 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4405 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4407 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4408 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4410 switch (pEventArg->GetEventType())
4412 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4414 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4415 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4417 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4418 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4420 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4435 _WebImpl::VibrationRequested(uint64_t duration)
4437 result r = E_SUCCESS;
4439 __pVibrator.reset();
4441 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4442 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4444 r = pVibrator->Construct();
4445 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4447 __pVibrator = std::move(pVibrator);
4449 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4451 r = __pVibrator->Start(&pattern, 1, 1);
4452 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4459 _WebImpl::VibrationCanceled(void)
4461 __pVibrator.reset();
4466 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4468 result r = E_SUCCESS;
4470 String host(ewk_auth_challenge_url_get(pChallenge));
4471 String realm(ewk_auth_challenge_realm_get(pChallenge));
4473 __pAuthChallenge.reset();
4475 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4476 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4478 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4479 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4481 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4482 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4484 __pAuthChallenge = std::move(pAuthChallenge);
4486 ewk_auth_challenge_suspend(pChallenge);
4487 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4489 __pAuthChallenge.release();
4493 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4494 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4502 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4504 result r = E_SUCCESS;
4506 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4507 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4509 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4510 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4512 __pAuthPopup = std::move(pAuthPopup);
4514 int modalResult = 0;
4516 __pAuthPopup->SetOwner(&GetPublic());
4518 r = __pAuthPopup->ShowAndWait(modalResult);
4519 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4522 __pAuthPopup.reset();
4529 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4531 result r = E_SUCCESS;
4533 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4534 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4536 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4537 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4539 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4541 int modalResult = 0;
4543 __pCertConfirmPopup->SetOwner(&GetPublic());
4545 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4546 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4548 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4550 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4554 __pCertConfirmPopup.reset();
4560 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4562 result r = E_SUCCESS;
4564 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4565 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4567 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
4568 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4570 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4572 int modalResult = 0;
4574 __pUserConfirmPopup->SetOwner(&GetPublic());
4576 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4577 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4580 __pUserConfirmPopup.reset();
4586 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4588 result r = E_SUCCESS;
4590 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4591 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4593 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
4594 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4596 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4598 __pUserConfirmPopup->SetOwner(&GetPublic());
4600 r = __pUserConfirmPopup->ShowPopup();
4601 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4603 __pUserConfirmPopup.release();
4608 __pUserConfirmPopup.reset();
4615 _WebImpl::GetParentFormCore(_Control* pControlCore)
4618 _Form* pFormCore = null;
4620 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4621 if (!pParentControlCore)
4626 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4632 return GetParentFormCore(pParentControlCore);
4637 _WebImpl::OnFocusGained(const _ControlImpl& source)
4644 _WebImpl::OnFocusLost(const _ControlImpl& source)
4646 if(IsKeypadVisible() == true)
4648 SetKeypadOpened(true);
4650 SetKeypadVisibleState(false);
4653 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4660 _WebImpl::HasValidNativeNode(void) const
4662 if (__pWebCore && __pWebCore->GetWebNativeNode())
4672 _WebImpl::OnPreAttachedToMainTree(void)
4674 result r = E_SUCCESS;
4676 r = __pWebCore->InitializeWebNativeNode();
4677 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4679 r = InitializeSetting();
4680 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4682 r = _ContainerImpl::OnPreAttachedToMainTree();
4683 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4690 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4692 _ContainerImpl::OnChangeLayout(orientation);
4694 if (__pColorPicker.get())
4696 __pColorPicker->ChangeLayout(orientation);
4699 __isOrientationChanged = true;
4704 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4706 if (IsVisible() == true)
4708 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4712 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4718 _WebImpl::GetDownloadHandler(void) const
4720 return __pWebDownloadHandler.get();
4725 _WebImpl::HideColorPicker(void)
4727 __pColorPicker.reset();
4734 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4736 result r = E_SUCCESS;
4738 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4739 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4741 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4743 r = pColorHadler->Construct(colorVal, this);
4744 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4746 __pColorPicker = std::move(pColorHadler);
4748 r = __pColorPicker->ShowPopup();
4749 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4751 color = __pColorPicker->GetColor();
4756 __pColorPicker.reset();
4763 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4765 result r = E_SUCCESS;
4767 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4768 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4770 r = pInputPicker->Construct(String(inputValue), inputType, this);
4771 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4773 __pDatePicker = std::move(pInputPicker);
4775 r = __pDatePicker->ShowPopup();
4776 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4778 dateStr = __pDatePicker->GetDate();
4781 __pDatePicker.reset();
4788 _WebImpl::GetInstance(Web* pWeb)
4790 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4795 _WebImpl::GetInstance(const Web* pWeb)
4797 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4802 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4804 int checkReturn = 0;
4806 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4809 if( checkmime == true)
4811 table = CUSTOM_CONTENT_TABLE_NAME;
4815 table = CUSTOM_PROTOCOL_TABLE_NAME;
4818 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4819 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4820 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4822 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4824 result r = db.Construct(handlerPath, "r+", null);
4825 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4827 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"'"));
4828 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4832 r = pEnum->MoveNext();
4833 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4834 r = pEnum->GetIntAt(0, checkReturn);
4835 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4847 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4851 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4854 if( checkmime == true)
4856 table = CUSTOM_CONTENT_TABLE_NAME;
4860 table = CUSTOM_PROTOCOL_TABLE_NAME;
4863 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4864 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4865 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4867 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4869 result r = db.Construct(handlerPath, "r+", null);
4870 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4872 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"'"));
4873 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4877 r = pEnum->MoveNext();
4878 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4879 r = pEnum->GetIntAt(0, checkId);
4880 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4882 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
4883 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4885 r = pDeleteStmt->BindInt(0, checkId);
4886 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4888 db.BeginTransaction();
4890 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
4892 db.CommitTransaction();
4899 const Tizen::Base::String
4900 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
4902 if (originUri == L"" || currentUri == L"")
4907 result r = E_SUCCESS;
4910 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4911 String originReplace(originUri);
4912 String table(CUSTOM_PROTOCOL_TABLE_NAME);
4916 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4917 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4919 r = currentUri.SubString(0, found + 1, baseUri);
4920 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4922 r = db.Construct(handlerPath, "r+", null);
4923 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4925 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
4926 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
4930 while (pEnum->MoveNext() == E_SUCCESS)
4935 String originScheme;
4937 r = pEnum->GetStringAt(0, protocol);
4938 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4940 r = pEnum->GetStringAt(1, queryUrl);
4941 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4943 r = pEnum->GetIntAt(2, allow);
4944 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4951 String protocolScheme(protocol + L":");
4953 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
4954 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4956 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
4958 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
4960 r = originReplace.Replace(originScheme, "");
4961 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4963 queryUrl.Replace("%s", originReplace, 0);
4964 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4976 const Tizen::Base::String
4977 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
4979 if (originUri == L"" || currentUri == L"" || mime == L"")
4984 result r = E_SUCCESS;
4987 String originUrlStr = originUri;
4988 const String replaceStr = L"%s";
4990 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4991 String table(CUSTOM_CONTENT_TABLE_NAME);
4995 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4996 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4998 r = currentUri.SubString(0, found + 1, baseUri);
4999 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5001 r = db.Construct(handlerPath, "r+", null);
5002 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5004 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5008 r = pEnum->MoveNext();
5009 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5010 r = pEnum->GetIntAt(0, allow);
5011 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5012 r = pEnum->GetStringAt(1, contentUrl);
5013 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5021 if (contentUrl != L"")
5023 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5024 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5035 }}} // Tizen::Web::Controls