2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_WebImpl.cpp
20 * @brief The file contains the definition of _WebImpl class.
22 * The file contains the definition of _WebImpl class.
24 #include <Ecore_IMF_Evas.h>
25 #include <Ecore_Evas.h>
26 #include <elm_config.h>
29 #include <ewk_popup_menu_item.h>
30 #include <libsoup/soup-status.h>
32 #include <FAppAppControl.h>
33 #include <FAppIAppControlListener.h>
34 #include <FBaseColAllElementsDeleter.h>
35 #include <FBaseColHashMapT.h>
36 #include <FBaseRtMutex.h>
37 #include <FBaseRtMutexGuard.h>
38 #include <FBaseSysLog.h>
39 #include <FBaseUtilUri.h>
40 #include <FCntDownloadRequest.h>
41 #include <FGrpColor.h>
42 #include <FGrpPoint.h>
43 #include <FGrpRectangle.h>
44 #include <FIoDbEnumerator.h>
45 #include <FIoDbStatement.h>
47 #include <FMediaImage.h>
48 #include <FMediaImageTypes.h>
49 #include <FNetHttpHttpHeader.h>
50 #include <FSysVibrator.h>
51 #include <FUiControl.h>
52 #include <FUiCtrlKeypad.h>
53 #include <FWebCtrlHitElementResult.h>
54 #include <FWebCtrlITextSearchListener.h>
55 #include <FWebCtrlIWebDownloadListener.h>
56 #include <FWebCtrlIWebUiEventListener.h>
57 #include <FWebCtrlIWebUiEventListenerF.h>
58 #include <FWebCtrlIWebKeypadEventListener.h>
59 #include <FWebCtrlIJavaScriptBridge.h>
60 #include <FWebCtrlPageNavigationList.h>
61 #include <FWebCtrlAuthenticationChallenge.h>
62 #include <FWebCtrlWeb.h>
63 #include <FWebCtrlWebSetting.h>
64 #include <FWebHistoryItem.h>
65 #include <FWebJsonJsonObject.h>
66 #include <FWebJsonJsonParser.h>
67 #include <FWebJsonJsonString.h>
68 #include <FApp_AppControlImpl.h>
69 #include <FApp_AppControlManager.h>
70 #include <FApp_AppInfo.h>
71 #include <FApp_AppManagerImpl.h>
72 #include <FBase_StringConverter.h>
73 #include <FCnt_DownloadManagerImpl.h>
74 #include <FCnt_ContentManagerImpl.h>
75 #include <FGrp_CoordinateSystem.h>
76 #include <FGrp_Screen.h>
77 #include <FIo_DatabaseImpl.h>
78 #include <FIo_NormalFile.h>
79 #include <FSys_SystemResource.h>
80 #include <FSys_VibratorImpl.h>
81 #include <FUi_Control.h>
82 #include <FUi_CoordinateSystemUtils.h>
83 #include <FUi_EcoreEvasMgr.h>
84 #include <FUi_EcoreEvas.h>
85 #include <FUi_ResourceSizeInfo.h>
86 #include <FUi_Window.h>
87 #include <FUiAnim_EflNode.h>
88 #include <FUiAnim_VisualElement.h>
89 #include <FUiCtrl_FooterImpl.h>
90 #include <FUiCtrl_Form.h>
91 #include "FWeb_HistoryItemImpl.h"
92 #include "FWebCtrl_AppControlListener.h"
93 #include "FWebCtrl_AuthConfirmPopup.h"
94 #include "FWebCtrl_AuthenticationChallengeImpl.h"
95 #include "FWebCtrl_EflWebkit.h"
96 #include "FWebCtrl_FormDataWindow.h"
97 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
98 #include "FWebCtrl_HitElementResultImpl.h"
99 #include "FWebCtrl_InputPickerPopup.h"
100 #include "FWebCtrl_WebNotification.h"
101 #include "FWebCtrl_PageNavigationListImpl.h"
102 #include "FWebCtrl_PromptPopup.h"
103 #include "FWebCtrl_SelectBox.h"
104 #include "FWebCtrl_Utility.h"
105 #include "FWebCtrl_Web.h"
106 #include "FWebCtrl_WebDataHandler.h"
107 #include "FWebCtrl_WebEvent.h"
108 #include "FWebCtrl_WebEventArg.h"
109 #include "FWebCtrl_WebImpl.h"
110 #include "FWebCtrl_WebPresenter.h"
111 #include "FWebCtrl_WebSettingImpl.h"
114 using namespace Tizen::App;
115 using namespace Tizen::Base;
116 using namespace Tizen::Base::Collection;
117 using namespace Tizen::Base::Runtime;
118 using namespace Tizen::Base::Utility;
119 using namespace Tizen::Content;
120 using namespace Tizen::Graphics;
121 using namespace Tizen::Io;
122 using namespace Tizen::Media;
123 using namespace Tizen::Net::Http;
124 using namespace Tizen::System;
125 using namespace Tizen::Ui;
126 using namespace Tizen::Ui::Animations;
127 using namespace Tizen::Ui::Controls;
128 using namespace Tizen::Web::Json;
131 namespace Tizen { namespace Web { namespace Controls
135 static const char WEB_CTRL[] = "webcontrol";
136 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
139 static const float MIN_ZOOM_LEVEL = 0.3;
140 static const float MAX_ZOOM_LEVEL = 2;
143 static const int REDIRECTION_HEADER_GROUP = 300;
146 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
149 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
150 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
151 static const int DEFAULT_LIST_ITEM_COUNT = 4;
155 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
157 result r = E_SUCCESS;
159 String key(reinterpret_cast< const char* >(pKey));
160 String value(reinterpret_cast< char* >(pValue));
162 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
164 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
165 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
172 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
174 result r = E_SUCCESS;
176 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
177 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
178 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
180 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
182 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
183 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
185 pAttrValue.release();
192 FreeCharArray(void* pData)
194 delete[] reinterpret_cast<char*>(pData);
199 ConvertErrorCode(int error)
201 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
205 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
207 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
209 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
211 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
213 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
215 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
217 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
219 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
221 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
223 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
225 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
227 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
229 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
231 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
232 errorCode = WEB_NO_CONNECTION;
235 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
237 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
238 errorCode = WEB_BAD_URL;
241 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
242 errorCode = WEB_FILE_ACCESS_FAILED;
245 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
246 errorCode = WEB_REQUEST_TIMEOUT;
249 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
250 errorCode = WEB_MIME_NOT_SUPPORTED;
253 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
254 errorCode = WEB_OUT_OF_MEMORY;
257 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
258 errorCode = WEB_REQUEST_MAX_EXCEEDED;
261 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
263 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
265 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
267 case EWK_ERROR_NETWORK_STATUS_OK:
269 case EWK_ERROR_NETWORK_STATUS_CREATED:
271 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
273 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
275 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
277 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
279 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
281 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
283 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
285 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
287 case EWK_ERROR_NETWORK_STATUS_FOUND:
289 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
291 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
293 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
295 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
297 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
298 errorCode = WEB_HTTP_RESPONSE;
301 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
302 errorCode = WEB_INVALID_CERTIFICATE;
306 errorCode = WEB_ERROR_UNKNOWN;
315 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
317 result r = E_SUCCESS;
319 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
320 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
321 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
322 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
324 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
325 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
326 pErrorCode.release();
328 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
329 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
330 pErrorDescription.release();
332 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
333 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
341 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
343 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
345 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
346 String msg(pMessage);
348 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
349 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
353 ewk_view_javascript_alert_reply(pView);
359 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
361 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
363 result r = E_SUCCESS;
364 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
365 String msg(pMessage);
367 MessageBox messageBox;
368 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
369 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
373 messageBox.SetOwner(&pImpl->GetPublic());
375 r = messageBox.ShowAndWait(modalResult);
376 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
378 if (modalResult == MSGBOX_RESULT_OK)
380 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
384 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
392 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
394 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
396 result r = E_SUCCESS;
397 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
399 String msg(pMessage);
400 String defVal(pDefaultValue);
402 r = pImpl->ShowPromptPopup(msg, defVal);
403 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
408 ewk_view_javascript_prompt_reply(pView, null);
415 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
417 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
418 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
419 SysAssertf(pImpl && pPolicy, "Failed to request");
421 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
423 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
425 if (pImpl->IsCertificateRequested())
427 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
431 result r = E_SUCCESS;
433 std::unique_ptr<DbEnumerator> pEnum;
435 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
436 String table(CERTIFICATE_TABLE_NAME);
439 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
441 r = db.Construct(certificatePath, "r", null);
442 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
444 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
447 r = pEnum->MoveNext();
448 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
451 r = pEnum->GetIntAt(0, allow);
452 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
454 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
456 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
457 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
461 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
462 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
467 pImpl->SetCertificateRequested(true);
471 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
472 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
474 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
475 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
484 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
485 pImpl->SetCertificateConfirmed(false);
486 pImpl->SetCertificateRequested(true);
491 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
493 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
494 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
495 SysAssertf(pImpl && pChallenge, "Failed to request");
497 result r = E_SUCCESS;
499 r = pImpl->HttpAuthenticationRequested(pChallenge);
500 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
504 ewk_auth_challenge_credential_cancel(pChallenge);
505 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
510 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
512 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
513 SysAssertf(pImpl , "Failed to request");
515 if (pImpl->GetLoadingListener())
517 result r = E_SUCCESS;
519 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
520 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
522 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
523 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
529 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
531 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
532 SysAssertf(pImpl , "Failed to request");
534 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
536 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
537 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
539 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
540 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
547 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
549 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
550 SysAssertf(pImpl , "Failed to request");
552 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
554 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
555 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
557 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
558 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
565 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
567 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
568 SysAssertf(pImpl , "Failed to request");
570 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
572 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
573 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
575 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
576 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
582 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
584 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
585 SysAssertf(pImpl , "Failed to request");
587 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
589 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
590 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
592 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
593 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
600 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
602 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
603 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
604 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
606 if (pImpl->GetSetting().IsGeolocationEnabled())
608 result r = E_SUCCESS;
610 std::unique_ptr<DbEnumerator> pEnum;
612 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
613 String table(GEOLOCATION_TABLE_NAME);
616 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
617 String origin = _Utility::CreateOrigin(pSecurityOrigin);
619 r = db.Construct(geolocationPath, "r", null);
620 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
622 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
625 r = pEnum->MoveNext();
626 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
629 r = pEnum->GetIntAt(0, permission);
630 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
632 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
634 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
638 ewk_geolocation_permission_request_suspend(pPermissionRequest);
640 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
641 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
648 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
653 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
655 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
656 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
657 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
659 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
660 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
664 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
669 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
671 result r = E_SUCCESS;
672 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
674 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
675 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
677 ewk_notification_permission_request_suspend(pPermissionRequest);
679 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
680 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
684 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
689 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
691 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
692 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
693 SysAssertf(pImpl && pNotification, "Failed to request");
695 result r = E_SUCCESS;
696 Ewk_Context* pContext = ewk_view_context_get(pView);
697 SysAssertf(pContext, "Failed to get webkit instance.");
698 uint64_t notificationId = ewk_notification_id_get(pNotification);
700 //ewk_notification_security_origin_get(pNotification)
702 const char* text = ewk_notification_body_get(pNotification);
703 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
705 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
706 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
708 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
709 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
711 pNotificationWindow->SetText(String(text));
712 pNotificationWindow->LaunchNotification();
713 pImpl->SetWebNotification(pNotificationWindow.release());
715 ewk_notification_showed(pContext, notificationId);
720 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
722 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
723 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
724 SysAssertf(pImpl && pNotificationID, "Failed to request");
726 //ToDo : Where is ewk API for cancel operation?
731 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
733 result r = E_SUCCESS;
734 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
735 SysAssertf(pImpl, "Failed to request");
737 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
738 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
743 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
745 int checkHandler = 0;
746 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
747 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
748 SysAssertf(pImpl && pHandlerData, "Failed to request");
750 checkHandler = pImpl->SearchHandler(pHandlerData, false);
751 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
752 switch (checkHandler)
757 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
760 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
763 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
771 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
773 result r = E_SUCCESS;
774 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
775 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
776 SysAssertf(pImpl && pHandlerData, "Failed to request");
778 r = pImpl->UnregistrationHandler(pHandlerData, false);
779 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
784 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
786 result r = E_SUCCESS;
787 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
788 SysAssertf(pImpl, "Failed to request");
790 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
791 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
796 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
798 int checkHandler = 0;
799 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
800 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
801 SysAssertf(pImpl && pHandlerData, "Failed to request");
803 checkHandler = pImpl->SearchHandler(pHandlerData, true);
804 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
806 switch (checkHandler)
811 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
814 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
817 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
826 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
828 result r = E_SUCCESS;
829 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
830 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
831 SysAssertf(pImpl && pHandlerData, "Failed to request");
833 r = pImpl->UnregistrationHandler(pHandlerData, true);
834 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
839 OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo)
841 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
842 SysAssertf(pImpl, "Failed to request");
844 SysLog(NID_WEB_CTRL, "Enter.");
849 OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
851 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
852 SysAssertf(pImpl, "Failed to request");
854 SysLog(NID_WEB_CTRL, "Exit.");
859 OnVibrationRequested(uint64_t duration, void* pUserData)
861 result r = E_SUCCESS;
863 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
864 SysAssertf(pImpl, "Failed to request");
866 r = pImpl->VibrationRequested(duration);
867 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
872 OnVibrationCanceled(void* pUserData)
874 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
875 SysAssertf(pImpl, "Failed to request");
877 pImpl->VibrationCanceled();
882 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
884 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
885 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
886 SysAssertf(pImpl && pPolicy, "Failed to request");
888 String url(ewk_policy_decision_url_get(pPolicy));
889 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
891 if (url == L"about:blank")
893 ewk_policy_decision_use(pPolicy);
897 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
898 && !pImpl->IsRedirectRequested())
900 pImpl->SetCertificateRequested(false);
902 if (pImpl->GetTextSearchListener())
904 pImpl->DisableAsyncSearch();
907 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
908 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
910 switch (ewkNavigationType)
912 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
913 navigationType = WEB_NAVIGATION_LINK_CLICKED;
915 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
916 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
918 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
919 navigationType = WEB_NAVIGATION_BACKFORWARD;
921 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
922 navigationType = WEB_NAVIGATION_RELOAD;
924 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
925 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
927 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
928 navigationType = WEB_NAVIGATION_OTHER;
934 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
936 ewk_policy_decision_ignore(pPolicy);
942 String currentUrl(pImpl->GetUrl());
943 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
944 if (redirectUrl != L"")
946 pImpl->LoadUrl(redirectUrl);
947 ewk_policy_decision_ignore(pPolicy);
955 String uriScheme(uri.GetScheme());
956 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
958 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
960 ewk_policy_decision_ignore(pPolicy);
962 if (uriScheme == L"")
967 result r = E_SUCCESS;
969 if (uriScheme == L"tel")
971 String operationId(L"http://tizen.org/appcontrol/operation/dial");
972 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
974 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
976 String operationId(L"http://tizen.org/appcontrol/operation/compose");
977 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
981 String operationId(L"http://tizen.org/appcontrol/operation/view");
982 String mime(ewk_policy_decision_response_mime_get(pPolicy));
983 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
985 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
990 ewk_policy_decision_use(pPolicy);
995 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
997 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
998 SysAssertf(pImpl, "Failed to request");
1000 if (pImpl->GetLoadingListener())
1002 result r = E_SUCCESS;
1004 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
1005 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1007 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1008 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1009 pEventArg.release();
1015 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1017 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1018 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1019 SysAssertf(pImpl, "Failed to request");
1021 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1023 if (pImpl->GetLoadingListener())
1025 result r = E_SUCCESS;
1027 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1028 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1029 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1031 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1032 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1033 pPageTitle.release();
1035 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1036 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1037 pEventArg.release();
1043 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1045 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1046 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1047 SysAssertf(pImpl, "Failed to request");
1049 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1051 if (pImpl->GetLoadingListener())
1053 result r = E_SUCCESS;
1055 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1056 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1057 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1059 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1060 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1061 pProgressPercentage.release();
1063 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1064 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1065 pEventArg.release();
1071 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1073 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1074 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1075 SysAssertf(pImpl && pPolicy, "Failed to request");
1077 result r = E_SUCCESS;
1079 _SystemResource* pSysResource = _SystemResource::GetInstance();
1080 SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
1082 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1083 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1084 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1085 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1087 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1089 String url(ewk_policy_decision_url_get(pPolicy));
1091 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1093 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1095 DecisionPolicy policy;
1096 HttpHeader httpHeader;
1098 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1100 pImpl->SetRedirectRequested(true);
1104 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1105 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1107 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1108 pImpl->SetPolicyDecision(policy);
1111 switch (pImpl->GetPolicyDecision())
1113 case WEB_DECISION_CONTINUE:
1115 String currentUrl(pImpl->GetUrl());
1116 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1117 if (redirectUrl != L"")
1119 pImpl->LoadUrl(redirectUrl);
1120 ewk_policy_decision_ignore(pPolicy);
1125 if (pImpl->IsMimeSupported(mime) || mime == L"")
1132 ewk_policy_decision_ignore(pPolicy);
1134 _SelectBox selectBox;
1135 int selectedIndex = 0;
1136 String operationId(L"http://tizen.org/appcontrol/operation/view");
1138 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1139 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1141 if (r == E_OBJ_NOT_FOUND)
1143 r = selectBox.Construct(false, L"Select application", 1); //+1 for Downloader
1144 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1146 selectBox.SetOwner(&pImpl->GetPublic());
1148 selectBox.AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1149 r = selectBox.ShowAndWait(selectedIndex);
1150 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1152 if (selectedIndex == 0) //download
1154 RequestId reqId = 0;
1155 DownloadRequest request(pUrl);
1157 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1158 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1160 r = pManagerImpl->Start(request, reqId);
1161 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1169 case WEB_DECISION_DOWNLOAD:
1171 ewk_policy_decision_ignore(pPolicy);
1173 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1174 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1176 Ewk_Context* pContext = ewk_view_context_get(pView);
1177 SysAssertf(pContext, "Failed to get webkit instance.");
1179 pDownloadHandler->StartDownload(pUrl);
1183 case WEB_DECISION_IGNORE:
1185 ewk_policy_decision_ignore(pPolicy);
1195 ewk_policy_decision_use(pPolicy);
1200 ewk_policy_decision_ignore(pPolicy);
1205 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1207 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1208 SysAssertf(pImpl, "Failed to request");
1210 if (pImpl->IsRedirectRequested())
1212 pImpl->SetRedirectRequested(false);
1215 if (pImpl->IsLoadingErrorOccurred())
1217 pImpl->SetLoadingErrorOccurred(false);
1218 evas_object_smart_callback_call(pView, "load,finished", NULL);
1224 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1226 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1227 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1228 SysAssertf(pImpl && pErrorData, "Failed to request");
1230 int code = ewk_error_code_get(pErrorData);
1231 const char* pDescription = ewk_error_description_get(pErrorData);
1233 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1237 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1238 pImpl->SetLoadingErrorOccurred(true);
1241 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1242 evas_object_smart_callback_call(pView, "load,finished", NULL);
1245 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1246 pImpl->SetLoadingErrorOccurred(true);
1247 evas_object_smart_callback_call(pView, "load,stop", NULL);
1251 pImpl->SetLoadingErrorOccurred(true);
1252 if (pImpl->GetLoadingListener())
1254 result r = E_SUCCESS;
1256 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1257 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1265 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1267 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1268 SysAssertf(pImpl, "Failed to request");
1270 if (pImpl->GetLoadingListener())
1272 result r = E_SUCCESS;
1274 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1275 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1277 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1278 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1279 pEventArg.release();
1286 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1288 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1289 SysAssertf(pImpl, "Failed to request");
1291 if (pImpl->GetLoadingListener())
1293 result r = E_SUCCESS;
1295 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1296 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1298 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1299 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1300 pEventArg.release();
1307 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1309 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1310 SysAssertf(pImpl, "Failed to request");
1312 if (pImpl->GetLoadingListener())
1314 result r = E_SUCCESS;
1316 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1317 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1319 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1320 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1321 pEventArg.release();
1328 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1330 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1331 SysAssertf(pUrl && pImpl != null, "Failed to request");
1333 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1338 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1340 result r = E_SUCCESS;
1342 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1343 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1345 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1346 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1347 pEventArg.release();
1354 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1356 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1357 SysAssertf(pImpl, "Failed to request");
1359 if (pImpl->GetUiEventListener())
1361 result r = E_SUCCESS;
1363 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1364 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1366 if (pImpl->GetUiEventListenerF())
1368 result r = E_SUCCESS;
1370 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1371 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1377 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1379 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1380 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1381 SysAssertf(pParentImpl && pChildView, "Failed to request");
1383 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1384 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1385 if (pUserUiListener)
1387 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1390 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1391 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1393 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1394 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1397 if (pUserUiListenerF)
1399 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1402 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1403 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1405 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1406 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1413 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1415 result r = E_SUCCESS;
1417 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1418 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1420 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1421 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1422 pEventArg.release();
1429 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1431 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1432 SysAssertf(pChildImpl, "Failed to request");
1434 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1435 if (pParentImpl == null)
1440 if (pParentImpl->GetUiEventListener())
1442 result r = E_SUCCESS;
1444 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1445 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1447 if (pParentImpl->GetUiEventListenerF())
1449 result r = E_SUCCESS;
1451 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1452 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1458 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1460 result r = E_SUCCESS;
1462 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1463 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1464 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1466 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1467 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1468 pPreventTrigger.release();
1470 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1471 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1472 pEventArg.release();
1479 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1481 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1482 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1483 SysAssertf(pImpl && pTrigger, "Failed to request");
1485 if (pImpl->GetUiEventListener())
1487 result r = E_SUCCESS;
1489 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1490 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1492 if (pImpl->GetUiEventListenerF())
1494 result r = E_SUCCESS;
1496 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1497 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1503 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1505 result r = E_SUCCESS;
1507 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1508 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1509 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1511 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1513 if ((endPoint->x != 0) && (endPoint->y != 0))
1515 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1516 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1518 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1519 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1520 startPoint.release();
1522 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1523 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1526 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1527 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1528 pEventArg.release();
1536 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1538 result r = E_SUCCESS;
1540 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1541 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1543 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1545 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1547 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1549 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1550 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1552 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1553 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1554 startPoint.release();
1556 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1557 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1560 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1561 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1562 pEventArg.release();
1570 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1572 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1573 SysAssertf(pImpl, "Failed to request");
1575 if (pImpl->GetUiEventListener())
1577 result r = E_SUCCESS;
1579 r = FireWebPageBlockSelectedEvent(pImpl);
1580 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1582 if (pImpl->GetUiEventListenerF())
1584 result r = E_SUCCESS;
1586 r = FireWebPageBlockSelectedEventF(pImpl);
1587 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1593 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1595 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1596 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1598 pMediaListener->Construct(pView);
1601 result r = extraData.Construct();
1602 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_TRUE, r, "[%s] Propagating.", GetErrorMessage(r));
1604 String isMultipleSelection(L"single");
1605 String mode(L"selectionType");
1606 String type(L"type");
1607 String fileType = L"*/*";
1608 String operationId = L"http://tizen.org/appcontrol/operation/pick";
1612 isMultipleSelection.Append(L"multiple");
1615 if (eina_list_count(pAcceptTypes) == 1)
1617 String item((char*)eina_list_nth(pAcceptTypes, 0));
1618 String captureString(pCapture);
1620 if (item.StartsWith("image/",0))
1622 if (captureString == L"camera")
1624 fileType = L"image/jpg";
1625 operationId = L"http://tizen.org/appcontrol/operation/create_content";
1626 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
1627 String typeVal = L"false";
1628 extraData.Add(&typeKey, &typeVal);
1632 fileType = L"image/*";
1633 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1634 extraData.Add(&selectKey, &isMultipleSelection);
1637 else if (item.StartsWith("audio/",0))
1639 fileType = L"audio/*";
1640 //TO DO: as microphone is not supported yet. suggest to throw an exception
1641 //if (captureString == L"microphone")
1643 //operationId = L"http://tizen.org/appcontrol/operation/create_content";
1647 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1648 extraData.Add(&selectKey, &isMultipleSelection);
1651 else if (item.StartsWith("video/",0))
1653 if (captureString == L"camcorder")
1655 fileType = L"video/3gpp";
1656 operationId = L"http://tizen.org/appcontrol/operation/create_content";
1657 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
1658 String typeVal = L"false";
1659 extraData.Add(&typeKey, &typeVal);
1663 fileType = L"video/*";
1664 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
1665 extraData.Add(&selectKey, &isMultipleSelection);
1670 r = _AppControlImpl::FindAndStart(operationId, null, &fileType, null, &extraData, pMediaListener.get());
1671 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1673 pMediaListener.release();
1678 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1684 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1686 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1687 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1688 SysAssertf(pImpl && pJsonText, "Failed to request");
1690 result r = E_SUCCESS;
1692 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1694 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1695 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1697 r = pEventArg->Construct(pJsonText);
1698 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1700 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1701 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1702 pEventArg.release();
1707 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1709 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1710 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1711 SysAssertf(pImpl && pEinaRect, "Failed to request");
1713 if (pImpl->IsVisible() == false)
1715 evas_object_focus_set(pView, EINA_FALSE);
1718 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1720 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1721 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1723 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1725 if (rect.height == 0)
1730 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1733 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1735 if (pFormCore->HasFooter())
1737 pFormCore->SetKeypadShowState(true);
1742 if (pImpl->GetWebKeypadEventListener())
1744 if (pImpl->IsKeypadVisible() == true)
1746 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1748 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1753 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1756 pImpl->SetKeypadVisibleState(true);
1757 pImpl->SetPreviousKeypadBounds(rect);
1761 result r = pImpl->SetFullScreenKeypad();
1762 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1768 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1770 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1771 SysAssertf(pImpl, "Failed to request");
1773 if (pImpl->GetWebKeypadEventListener())
1775 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1781 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1783 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1784 SysAssertf(pImpl, "Failed to request");
1786 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1789 pFormCore->DeflateClientRectHeight(0);
1791 if (pFormCore->HasFooter())
1793 pFormCore->SetKeypadShowState(false);
1798 if (pImpl->GetWebKeypadEventListener())
1800 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1803 pImpl->SetKeypadVisibleState(false);
1808 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1810 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1811 SysAssertf(pImpl, "Failed to request");
1813 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true && pImpl->IsFocused() == true)
1815 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1816 SysAssertf(pWebCore, "Failed to get Web core object");
1818 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1820 pImpl->SetKeypadVisibleState(true);
1826 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1828 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1829 SysAssertf(pImpl, "Failed to request");
1831 if (pImpl->IsKeypadOpened() == true)
1833 pImpl->SetKeypadOpened(false);
1839 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1841 SysAssertf(pSmartData, "invalid smartdata");
1842 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1843 SysAssertf(pWebImpl, "Failed to get Impl");
1845 result r = E_SUCCESS;
1847 if (pWebImpl->GetColorpicker())
1854 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1855 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1857 byte r1, g1, b1, a1;
1858 color.GetColorComponents(r1, g1, b1, a1);
1859 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1866 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1868 SysAssertf(pSmartData, "invalid smartdata");
1870 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1871 SysAssertf(pWebImpl, "Failed to get Impl");
1873 return pWebImpl->HideColorPicker();
1878 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1880 SysAssertf(pSmartData, "Failed to request");
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->GetDatepicker())
1888 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1895 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1896 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1898 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1899 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1901 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1908 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1910 SysAssertf(pSmartData, "Failed to request");
1912 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1913 SysAssertf(pWebImpl, "Failed to get Impl");
1915 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1916 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1923 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1925 SysAssertf(pSmartData, "Failed to request");
1927 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1928 SysAssertf(pWebImpl, "Failed to get Impl");
1930 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1931 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1938 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1940 SysAssertf(pSmartData, "invalid smartdata");
1942 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1943 SysAssertf(pWebImpl, "Failed to get Impl");
1945 result r = pWebImpl->ClearSelectBoxPopup();
1946 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1953 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1955 SysAssertf(pSmartData, "invalid smartdata");
1957 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1958 SysAssertf(pWebImpl, "Failed to get Impl");
1960 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1961 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1968 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1970 SysAssertf(pSmartData, "Failed to request");
1972 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1973 SysAssertf(pWebImpl, "Failed to get Impl");
1975 Rectangle windowRect(x, y, w, h);
1976 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1977 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1984 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
1986 SysAssertf(pSmartData, "Failed to request");
1988 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1989 SysAssertf(pWebImpl, "Failed to get Impl");
1991 if (pWebImpl->IsFormDataWindowVisible())
1993 pWebImpl->HideFormDataWindow();
2001 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
2003 SysAssertf(pSmartData, "Failed to request");
2005 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2006 SysAssertf(pWebImpl, "Failed to get Impl");
2008 pWebImpl->SetFormDataList(pDataList);
2015 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
2017 SysAssertf(pSmartData, "Failed to request");
2019 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2020 SysAssertf(pWebImpl, "Failed to get Impl");
2022 if (pWebImpl->IsFormDataWindowVisible())
2034 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2036 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2037 SysAssertf(pPresenter && !pError, "Failed to request");
2039 bool ret = EINA_TRUE;
2043 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2045 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2049 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2058 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2060 pPresenter->EndAsyncProcess(ret);
2065 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2067 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2068 SysAssertf(pPresenter, "Failed to request");
2070 String result(pResult);
2071 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2073 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2074 if (pImpl && pImpl->IsPresenterAlived(pPresenter))
2076 pPresenter->EndAsyncProcess(result);
2082 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2084 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2085 SysAssertf(pImpl, "Failed to request");
2087 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2088 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2090 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2094 pWebPresenter->EndAsyncProcess(*pTotalCount);
2098 if (pImpl->GetTextSearchListener())
2100 result r = E_SUCCESS;
2104 if (*pTotalCount > 0)
2106 ordinal = pImpl->GetAsyncSearchOrdinal();
2107 pImpl->SetAsyncSearchResult(*pTotalCount);
2110 if (pImpl->GetPendingAsyncSearchCount() > 0)
2115 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2116 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2117 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2118 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2120 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2121 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2124 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2125 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2128 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2129 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2130 pEventArg.release();
2136 class _JsBridgeHashCodeProvider
2137 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2140 _JsBridgeHashCodeProvider(){}
2141 virtual ~_JsBridgeHashCodeProvider(void) {}
2144 int GetHashCode(const Tizen::Base::String& obj) const
2146 return obj.GetHashCode();
2152 //Comparer implementation
2153 class _JsBridgeComparer
2154 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2157 _JsBridgeComparer(){}
2158 virtual ~_JsBridgeComparer(void) {}
2161 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2178 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2179 : _ContainerImpl(pWeb, pCore)
2180 , __isFooterVisible(false)
2181 , __isKeypadVisible(false)
2182 , __isKeypadOpened(false)
2183 , __isLoadingErrorOccurred(false)
2184 , __isRedirectRequested(false)
2185 , __isCertificateRequested(false)
2186 , __isCertificateConfirmed(false)
2187 , __isFormDataVisible(false)
2188 , __keypadBounds(0, 0, 0, 0)
2190 , __pUserLoadingListener(null)
2191 , __pUserUiListener(null)
2192 , __pUserUiListenerF(null)
2193 , __pUserKeypadEventListener(null)
2194 , __pTextSearchListener(null)
2196 , __pJsBridgeList(null)
2197 , __pJsProvider(null)
2198 , __pJsComparer(null)
2199 , __pWebDownloadHandler(null)
2201 , __pAuthChallenge(null)
2202 , __pAuthPopup(null)
2203 , __pUserMediaConfirmPopup(null)
2204 , __pContentHandlerConfirmPopup(null)
2205 , __pProtocolHandlerConfirmPopup(null)
2206 , __pGeolocationConfirmPopup(null)
2207 , __pNotificationConfirmPopup(null)
2208 , __pScriptAlertConfirmPopup(null)
2209 , __pAppCacheConfirmPopup(null)
2210 , __pDbQuotaConfirmPopup(null)
2211 , __pLocalFsQuotaConfirmPopup(null)
2212 , __pIndexedDbQuotaConfirmPopup(null)
2213 , __pPromptPopup(null)
2214 , __pCertConfirmPopup(null)
2215 , __pSelectBox(null)
2216 , __pDatePicker(null)
2217 , __pColorPicker(null)
2218 , __pFormDataWindow(null)
2220 , __policy(WEB_DECISION_CONTINUE)
2221 , __defaultUserAgent(L"")
2222 , __pFormDataList(null)
2224 __textSearch.__searchAll = false;
2225 __textSearch.__searchForward = true;
2226 __textSearch.__caseSensitive = false;
2227 __textSearch.__pending = 0;
2228 __textSearch.__currentIndex = 1;
2229 __textSearch.__totalCount = -1;
2230 __textSearch.__text = L"";
2234 _WebImpl::~_WebImpl()
2236 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2237 pManagerImpl->SetDownloadListener(null);
2239 RemoveEventListenerCallback();
2240 ClearCertificateDb();
2245 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2247 result r = E_SUCCESS;
2249 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2250 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2252 _Web* pCore = _Web::CreateWebN();
2253 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2255 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2257 r = CheckConstruction(pCore, pImpl);
2258 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2260 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2261 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2263 r = pImpl->Construct();
2264 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2276 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2278 result r = E_SUCCESS;
2280 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2281 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2283 _Web* pCore = _Web::CreateWebN();
2284 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2286 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2288 r = CheckConstruction(pCore, pImpl);
2289 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2291 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2292 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2294 r = pImpl->Construct();
2295 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2307 _WebImpl::Construct(void)
2309 result r = E_SUCCESS;
2311 r = __mutex.Create();
2312 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2314 r = __textSearch.__searchQueue.Construct();
2315 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2317 r = __callbackList.Construct();
2318 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2320 r = __webNotificationList.Construct();
2321 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2323 r = InitJsBridgeList();
2324 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2327 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2329 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2330 SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2332 pManagerImpl->SetDownloadListener(this);
2334 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2335 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2342 _WebImpl::InitializeSetting(void)
2344 result r = E_SUCCESS;
2346 WebSetting* pWebSetting = __pWebCore->GetSetting();
2347 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2349 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2350 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2352 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2354 r = SetSetting(*pWebSetting);
2355 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2357 SetEventListenerCallback();
2364 _WebImpl::IsLayoutable(void) const
2371 _WebImpl::InitWebEvent(void)
2373 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2374 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2376 return __pWebEvent->Construct(*this);
2381 _WebImpl::GetWebEvent(void) const
2383 return __pWebEvent.get();
2388 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2390 Eina_Hash* pHttpHeader = null;
2392 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2393 if (pFieldNameList.get())
2395 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2396 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2398 int count = pFieldNameList->GetCount();
2400 for (int i = 0; i < count; i++)
2402 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2403 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2405 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2406 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2408 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2409 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2411 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2413 Eina_Bool ret = false;
2415 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2416 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2418 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2419 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2421 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2422 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2429 eina_hash_free(pHttpHeader);
2436 _WebImpl::LoadUrl(const String& url) const
2438 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2439 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2441 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2448 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2450 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2451 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2453 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2455 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2457 eina_hash_free(pHttpHeader);
2464 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2466 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2467 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2469 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2471 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2473 eina_hash_free(pHttpHeader);
2480 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2482 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2484 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2485 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2486 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2487 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2489 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2496 _WebImpl::Pause(void)
2498 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2503 _WebImpl::Resume(void)
2505 ewk_view_resume(__pWebCore->GetWebNativeNode());
2510 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2512 __pSelectBox.reset();
2514 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2516 result r = E_SUCCESS;
2518 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2519 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2521 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2522 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2524 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2525 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2527 __pSelectBox = std::move(pSelectBox);
2529 __pSelectBox->SetOwner(&GetPublic());
2531 return __pSelectBox->ShowPopup();
2536 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2538 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2540 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2545 _WebImpl::ClearSelectBoxPopup(void)
2547 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2549 __pSelectBox.reset();
2556 _WebImpl::GetDatepicker(void)
2558 _InputPickerPopup* pInputPicker =null;
2561 pInputPicker = __pDatePicker.get();
2563 return pInputPicker;
2568 _WebImpl::GetColorpicker(void)
2570 _InputPickerPopup* pInputPicker =null;
2573 pInputPicker = __pColorPicker.get();
2575 return pInputPicker;
2580 _WebImpl::CanGoBack(void) const
2582 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2587 _WebImpl::CanGoForward(void) const
2589 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2594 _WebImpl::GoBack(void) const
2596 ewk_view_back(__pWebCore->GetWebNativeNode());
2601 _WebImpl::GoForward(void) const
2603 ewk_view_forward(__pWebCore->GetWebNativeNode());
2608 _WebImpl::GetUrl(void) const
2610 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2615 _WebImpl::GetTitle(void) const
2617 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2622 _WebImpl::StopLoading(void) const
2624 ewk_view_stop(__pWebCore->GetWebNativeNode());
2629 _WebImpl::Reload(void) const
2631 ewk_view_reload(__pWebCore->GetWebNativeNode());
2636 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2638 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2644 result r = E_SUCCESS;
2646 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2647 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2649 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
2650 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2652 r = __callbackList.Add(pPresenter.get());
2653 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2655 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2657 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2658 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2659 pPresenter->WaitAsyncProcess(*pResult.get());
2661 r = __callbackList.Remove(*pPresenter.get());
2662 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2663 pPresenter.release();
2665 return pResult.release();
2670 _WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
2672 return __callbackList.Contains(*pPresenter);
2677 _WebImpl::SetZoomLevel(float level)
2679 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);
2681 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2688 _WebImpl::GetZoomLevel(void) const
2690 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2694 const PageNavigationList*
2695 _WebImpl::GetBackForwardListN(void) const
2697 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2703 result r = E_SUCCESS;
2705 _PageNavigationListImpl* pNavigationListImpl = null;
2706 _HistoryItemImpl* pHistoryItemImpl = null;
2708 std::unique_ptr<PageNavigationList> pNavigationList;
2709 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2712 int forwardCount = 0;
2717 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2718 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2720 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2721 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2723 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2724 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2726 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2727 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2729 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2730 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2732 r = pHistoryList->Construct();
2733 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2735 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2736 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2737 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2739 for (int i = -backCount; i < forwardCount + 1; i++)
2741 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2742 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2744 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2745 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2747 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2748 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2750 url = ewk_history_item_uri_get(pEwkItem);
2751 title = ewk_history_item_title_get(pEwkItem);
2752 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2754 pHistoryItemImpl->SetHistoryItem(url, title);
2756 r = pHistoryList->Add(*pHistoryItem.get());
2757 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2758 pHistoryItem.release();
2761 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2763 ewk_history_free(pEwkHistoryList);
2765 return pNavigationList.release();
2768 ewk_history_free(pEwkHistoryList);
2775 _WebImpl::SearchText(const String& text, bool searchForward)
2777 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2783 result r = E_SUCCESS;
2785 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2789 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2792 _WebPresenter presenter;
2793 presenter.InitAsyncProcess();
2795 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, &presenter);
2796 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2799 presenter.WaitAsyncProcess(result);
2801 return static_cast < bool >(result);
2806 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2808 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2814 result r = E_SUCCESS;
2816 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2820 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2823 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2824 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2831 _WebImpl::SearchNextAsync(bool searchForward)
2833 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2839 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2840 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2841 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2843 result r = E_SUCCESS;
2845 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2847 if (!__textSearch.__caseSensitive)
2849 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2854 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2857 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2858 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2865 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2867 MutexGuard lock(__mutex);
2869 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2870 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2875 if (__textSearch.__searchAll)
2877 DisableAsyncSearch();
2879 __textSearch.__searchQueue.Enqueue(this);
2880 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2882 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2883 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2887 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2889 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2893 case SEARCH_ALL_ASYNC:
2894 __textSearch.__searchAll = true;
2895 __textSearch.__text = text;
2896 __textSearch.__searchForward = true;
2897 __textSearch.__caseSensitive = caseSensitive;
2898 __textSearch.__totalCount = -1;
2899 __textSearch.__currentIndex = 1;
2901 __textSearch.__searchQueue.Enqueue(this);
2902 __textSearch.__searchQueue.Enqueue(this);
2904 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2905 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2908 case SEARCH_NEXT_ASYNC:
2909 __textSearch.__searchForward = searchForward;
2911 CalculateAsyncSearchOrdinal();
2913 __textSearch.__searchQueue.Enqueue(this);
2915 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2927 _WebImpl::SetAsyncSearchResult(int totalCount)
2929 __textSearch.__totalCount = totalCount;
2934 _WebImpl::GetSearchPresenter(void)
2936 MutexGuard lock(__mutex);
2938 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2943 _WebImpl::GetPendingAsyncSearchCount(void) const
2945 return __textSearch.__searchQueue.GetCount();
2950 _WebImpl::CalculateAsyncSearchOrdinal(void)
2952 if (__textSearch.__searchForward)
2954 __textSearch.__currentIndex++;
2958 __textSearch.__currentIndex--;
2964 _WebImpl::GetAsyncSearchOrdinal(void) const
2966 return __textSearch.__currentIndex;
2971 _WebImpl::DisableAsyncSearch(void)
2973 __textSearch.__searchAll = false;
2978 _WebImpl::SetSetting(const WebSetting& setting)
2980 if (__pWebCore->GetWebNativeNode())
2982 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2983 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2984 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2986 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2987 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2989 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2991 switch (setting.GetCacheControl())
2993 case WEB_CACHE_VALIDATED:
2994 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2997 case WEB_CACHE_IGNORE:
2998 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
3005 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
3007 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
3011 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
3014 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
3016 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
3018 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
3020 if (__defaultUserAgent != setting.GetUserAgent())
3022 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
3023 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3025 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
3028 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
3030 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
3032 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3034 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3037 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3039 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3040 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3041 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3042 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3043 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3044 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3045 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3046 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3047 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3048 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3049 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3050 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3051 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3058 _WebImpl::GetSetting(void) const
3060 return *__pWebCore->GetSetting();
3064 const HitElementResult*
3065 _WebImpl::GetElementByPointN(const Point& point) const
3067 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3071 const HitElementResult*
3072 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3074 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3080 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));
3082 result r = E_SUCCESS;
3084 _HitElementResultImpl* pHitElementResultImpl = null;
3086 std::unique_ptr<HitElementResult> pHitElementResult;
3087 std::unique_ptr<Bitmap> pImage;
3088 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3090 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3092 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3093 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3095 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3096 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3097 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3098 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3099 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3101 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3103 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3104 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3106 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3107 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3109 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3115 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3116 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3117 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3118 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3120 r = buf.Construct(imageLength);
3121 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3123 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3124 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3128 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3129 // webkit support types such as ico and vp8 additionally
3130 if (strcmp(pExtension, "gif") == 0)
3132 format = IMG_FORMAT_GIF;
3134 else if (strcmp(pExtension, "jpg") == 0)
3136 format = IMG_FORMAT_JPG;
3138 else if (strcmp(pExtension, "png") == 0)
3140 format = IMG_FORMAT_PNG;
3142 else if (strcmp(pExtension, "bmp") == 0)
3144 format = IMG_FORMAT_BMP;
3148 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3152 r = image.Construct();
3153 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3155 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3156 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3161 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3162 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3164 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3165 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3167 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3168 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3171 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3173 ewk_hit_test_free(pEwkHitTest);
3175 return pHitElementResult.release();
3178 ewk_hit_test_free(pEwkHitTest);
3185 _WebImpl::IsLoading(void) const
3187 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3189 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3201 _WebImpl::GetTextFromBlock(void) const
3203 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3208 _WebImpl::IsPrivateBrowsingEnabled(void) const
3210 if (__pWebCore->GetWebNativeNode() == null)
3212 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3215 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3216 SysAssertf(pSettings, "Failed to get webkit instance.");
3218 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3223 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3225 if (__pWebCore->GetWebNativeNode() == null)
3227 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3231 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3232 SysAssertf(pSettings, "Failed to get webkit instance.");
3234 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3239 _WebImpl::ClearHistory(void)
3241 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3246 _WebImpl::ClearCache(void)
3248 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3250 ewk_context_cache_clear(pContext);
3255 _WebImpl::ClearCookie(void)
3257 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3258 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3260 ewk_cookie_manager_cookies_clear(pCookieManager);
3265 _WebImpl::ClearFormData(void)
3267 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3269 ewk_context_form_candidate_data_clear(pContext);
3274 _WebImpl::ClearLoginFormData(void)
3276 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3278 ewk_context_form_password_data_clear(pContext);
3283 _WebImpl::IsCookieEnabled(void) const
3285 if (__pWebCore->GetWebNativeNode() == null)
3287 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3290 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3291 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3292 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3294 _WebPresenter presenter;
3295 presenter.InitAsyncProcess();
3297 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3299 bool result = false;
3300 presenter.WaitAsyncProcess(result);
3307 _WebImpl::SetCookieEnabled(bool enable)
3309 if (__pWebCore->GetWebNativeNode() == null)
3311 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3316 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3317 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3318 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3322 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3326 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3327 ewk_cookie_manager_cookies_clear(pCookieManager);
3333 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3335 result r = E_SUCCESS;
3337 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3338 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3341 String fileExtension = File::GetFileExtension(filePath);
3342 int pathLength = filePath.GetLength();
3345 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3347 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3348 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3349 r = filePath.SubString(0, index + 1, dirPath);
3350 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3352 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3353 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3357 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3359 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3363 Evas_Coord contentsWidth;
3364 Evas_Coord contentsHeight;
3366 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3367 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3375 _WebImpl::IsMimeSupported(const String& mime) const
3377 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3378 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3380 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3385 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3387 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3392 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3394 __pUserUiListener = pUiEventListener;
3399 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3401 __pUserUiListenerF = pUiEventListener;
3406 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3408 __pUserKeypadEventListener = pKeypadEventListener;
3413 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3415 if (__pWebDownloadHandler.get() == null)
3417 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3418 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3421 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3422 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3427 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3429 __pTextSearchListener = pTextSearchListener;
3434 _WebImpl::SetScrollEnabled(bool enable)
3436 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3441 _WebImpl::IsScrollEnabled(void) const
3443 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3448 _WebImpl::InitJsBridgeList(void)
3450 result r = E_SUCCESS;
3452 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3453 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3455 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3456 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3458 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3459 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3461 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3462 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3464 __pJsBridgeList = std::move(pJsBridgeList);
3471 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3473 result r = E_SUCCESS;
3475 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3476 String key(pJsBridge->GetName());
3478 r = __pJsBridgeList->Add(key, pJsBridge);
3479 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3486 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3488 result r = E_SUCCESS;
3490 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3491 String key(pJsBridge->GetName());
3493 r = __pJsBridgeList->Remove(key);
3494 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3501 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3503 result r = E_SUCCESS;
3505 IJsonValue* pJsonValue = null;
3506 IJavaScriptBridge* pJsBridge = null;
3508 String key(L"name");
3510 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3511 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));
3513 r = pJsonObject->GetValue(&key, pJsonValue);
3514 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3516 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3517 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3519 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3520 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3527 _WebImpl::GetLoadingListener(void) const
3529 return __pUserLoadingListener;
3533 IWebUiEventListener*
3534 _WebImpl::GetUiEventListener(void) const
3536 return __pUserUiListener;
3540 IWebUiEventListenerF*
3541 _WebImpl::GetUiEventListenerF(void) const
3543 return __pUserUiListenerF;
3547 IWebKeypadEventListener*
3548 _WebImpl::GetWebKeypadEventListener(void) const
3550 return __pUserKeypadEventListener;
3554 ITextSearchListener*
3555 _WebImpl::GetTextSearchListener(void) const
3557 return __pTextSearchListener;
3562 _WebImpl::SetEventListenerCallback(void) const
3564 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3567 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3568 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3570 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3571 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3573 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3574 SysAssertf(pSmartData, "Failed to request");
3576 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3577 SysAssertf(pSmart, "Failed to request");
3579 pSmart->popup_menu_show = OnSelectBoxRequested;
3580 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3581 pSmart->popup_menu_hide = OnSelectBoxClosed;
3582 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3584 pSmart->input_picker_show = OnDatePickerProviderRequested;
3585 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3586 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3588 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3589 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3590 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3591 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3593 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3595 // add loading event callbacks for ILoadingListener
3596 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3597 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3599 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3600 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3601 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3602 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3603 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3604 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3605 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3606 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3608 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3610 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3612 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3613 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3614 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3616 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3617 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3619 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3621 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3622 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3623 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3625 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3627 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3628 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3629 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3631 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3632 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3633 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3635 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3636 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3637 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3639 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3640 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3641 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3642 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3644 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3645 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3647 evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
3649 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
3650 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
3652 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3653 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3654 SysAssertf(pContext, "Failed to get webkit instance.");
3655 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3656 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3658 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3659 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3660 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3661 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3663 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3669 _WebImpl::RemoveEventListenerCallback(void) const
3671 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3674 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3675 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3677 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3678 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3680 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3681 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3683 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3684 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3685 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3686 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3687 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3688 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3689 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3690 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3692 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3694 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3696 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3697 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3698 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3700 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3701 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3703 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3705 ewk_view_javascript_alert_callback_set(null, null, null);
3706 ewk_view_javascript_prompt_callback_set(null, null, null);
3707 ewk_view_javascript_confirm_callback_set(null, null, null);
3709 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3711 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3712 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3713 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3715 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3716 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3717 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3718 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3719 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3720 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3722 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3723 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3724 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3726 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3728 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3729 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3731 evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
3733 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
3734 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
3736 ewk_view_open_panel_callback_set(null, null, null);
3737 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3738 SysAssertf(pContext, "Failed to get webkit instance.");
3739 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3741 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3742 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3743 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3744 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3746 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3752 _WebImpl::ClearCertificateDb(void)
3754 result r = E_SUCCESS;
3756 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3757 String table(CERTIFICATE_TABLE_NAME);
3760 r = db.Construct(certificatePath, "r+", null);
3761 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3763 db.BeginTransaction();
3765 r = db.ExecuteSql(L"Delete From " + table, true);
3766 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3768 db.CommitTransaction();
3773 db.RollbackTransaction();
3778 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3780 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3785 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3787 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3788 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
3789 if (pSmartData && pSmartData->api)
3791 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3793 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3796 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3798 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3799 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3801 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3803 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3805 ewk_view_command_execute(pView, "SelectWord", 0);
3809 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3810 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3813 ewk_view_command_execute(pView, "SelectWord", 0);
3819 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3821 evas_object_smart_callback_call(pView, "text,selected", NULL);
3828 _WebImpl::ReleaseBlock(void)
3830 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3835 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3837 FloatPoint tempStartPoint;
3838 FloatPoint tempEndPoint;
3840 GetBlockRange(tempStartPoint, tempEndPoint);
3842 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3843 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3848 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3850 Eina_Rectangle leftHandle;
3851 Eina_Rectangle rightHandle;
3853 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3854 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3856 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3858 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3859 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3860 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3861 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3863 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3865 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3866 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3872 _WebImpl::GetFaviconN(void) const
3874 result r = E_SUCCESS;
3876 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3877 Ewk_Context* pContext = ewk_view_context_get(pView);
3878 const char* pUrl = ewk_view_url_get(pView);
3879 Evas* pEvas = evas_object_evas_get(pView);
3881 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3887 Tizen::Graphics::BufferInfo bufferInfo;
3889 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3890 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3892 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3893 Tizen::Base::ByteBuffer byteBuffer;
3895 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3896 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3898 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3899 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3901 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3902 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3904 return pImage.release();
3910 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3912 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3917 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3919 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3924 _WebImpl::GetScrollPosition(void) const
3928 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3935 _WebImpl::GetPageSize(void) const
3937 Evas_Coord width = 0;
3938 Evas_Coord height = 0;
3940 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3942 Dimension size(static_cast< int >(width), static_cast< int >(height));
3949 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
3951 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3953 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3954 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3956 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
3958 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
3965 _WebImpl::RemoveHttpHeaderField(const String& name)
3967 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3969 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3970 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3972 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
3979 _WebImpl::SetLoadingErrorOccurred(bool arg)
3981 __isLoadingErrorOccurred = arg;
3986 _WebImpl::IsLoadingErrorOccurred(void) const
3988 return __isLoadingErrorOccurred;
3993 _WebImpl::SetRedirectRequested(bool arg)
3995 __isRedirectRequested = arg;
4000 _WebImpl::IsRedirectRequested(void) const
4002 return __isRedirectRequested;
4007 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
4014 _WebImpl::GetPolicyDecision(void) const
4021 _WebImpl::SetCertificateRequested(bool arg)
4023 __isCertificateRequested = arg;
4028 _WebImpl::IsCertificateRequested(void) const
4030 return __isCertificateRequested;
4035 _WebImpl::SetCertificateConfirmed(bool arg)
4037 __isCertificateConfirmed = arg;
4042 _WebImpl::IsCertificateConfirmed(void) const
4044 return __isCertificateConfirmed;
4049 _WebImpl::SetFullScreenKeypad(void)
4051 result r = E_SUCCESS;
4053 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4054 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4056 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4057 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4059 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4060 pKeypad->SetText(text);
4062 r = pKeypad->SetShowState(true);
4063 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4065 r = pKeypad->Show();
4066 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4068 pKeypad->AddTextEventListener(*this);
4070 __pKeypad = std::move(pKeypad);
4077 _WebImpl::RemoveFullScreenKeypad(void)
4079 __pKeypad->RemoveTextEventListener(*this);
4086 _WebImpl::IsFooterVisible(void) const
4088 return __isFooterVisible;
4093 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4095 __isFooterVisible = isFooterVisible;
4100 _WebImpl::IsKeypadVisible(void) const
4102 return __isKeypadVisible;
4107 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4109 __isKeypadVisible = isKeypadVisible;
4114 _WebImpl::IsKeypadOpened(void) const
4116 return __isKeypadOpened;
4120 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4122 __isKeypadOpened = isKeypadOpened;
4127 _WebImpl::GetPreviousKeypadBounds(void) const
4129 return __keypadBounds;
4134 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4136 __keypadBounds = bounds;
4141 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4143 RemoveFullScreenKeypad();
4148 _WebImpl::OnTextValueChanged(const Control& source)
4150 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4152 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4154 RemoveFullScreenKeypad();
4159 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4161 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4162 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4164 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4165 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4167 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4168 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4170 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4177 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4179 result r = E_SUCCESS;
4181 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4182 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4184 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4186 ILoadingListener* pLoadingListner = GetLoadingListener();
4187 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4189 switch (pEventArg->GetEventType())
4191 case WEB_EVENT_LOADINGLISTENER_STARTED:
4193 pLoadingListner->OnLoadingStarted();
4197 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4199 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4200 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4202 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4206 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4208 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4209 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4211 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4215 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4217 pLoadingListner->OnLoadingCanceled();
4221 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4223 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4224 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4226 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4227 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4229 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4231 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4235 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4237 pLoadingListner->OnLoadingCompleted();
4241 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4243 pLoadingListner->OnHttpAuthenticationCanceled();
4247 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4249 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4250 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4254 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4270 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4272 result r = E_SUCCESS;
4274 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&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 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4280 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4282 switch (pEventArg->GetEventType())
4284 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4286 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4287 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4289 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4293 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4295 pWebDownloadListener->OnWebDataDownloadCompleted();
4299 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4301 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4302 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4304 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4306 pWebDownloadListener->OnWebDownloadFailed(errorType);
4321 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4323 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4324 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4326 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4328 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4330 switch (pEventArg->GetEventType())
4332 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4334 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4336 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4337 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4339 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4340 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4342 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4346 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4348 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4350 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4354 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4356 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4358 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4362 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4364 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4366 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4367 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4369 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4384 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4386 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4387 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4389 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4391 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4393 switch (pEventArg->GetEventType())
4395 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4397 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4399 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4400 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4402 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4403 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4405 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4409 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4411 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4413 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4417 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4419 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4421 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4425 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4427 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4429 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4430 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4432 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4447 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4449 result r = E_SUCCESS;
4451 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4452 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4454 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4456 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4457 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4459 switch (pEventArg->GetEventType())
4461 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4463 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4464 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4466 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4467 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4469 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4484 _WebImpl::VibrationRequested(uint64_t duration)
4486 result r = E_SUCCESS;
4488 __pVibrator.reset();
4490 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4491 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4493 r = pVibrator->Construct();
4494 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4496 __pVibrator = std::move(pVibrator);
4498 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4500 r = __pVibrator->Start(&pattern, 1, 1);
4501 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4508 _WebImpl::VibrationCanceled(void)
4510 __pVibrator.reset();
4515 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4517 result r = E_SUCCESS;
4519 String host(ewk_auth_challenge_url_get(pChallenge));
4520 String realm(ewk_auth_challenge_realm_get(pChallenge));
4522 __pAuthChallenge.reset();
4524 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4525 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4527 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4528 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4530 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4531 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4533 __pAuthChallenge = std::move(pAuthChallenge);
4535 ewk_auth_challenge_suspend(pChallenge);
4536 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4538 __pAuthChallenge.release();
4542 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4543 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4551 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4553 result r = E_SUCCESS;
4555 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4556 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4558 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4559 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4561 __pAuthPopup = std::move(pAuthPopup);
4563 int modalResult = 0;
4565 __pAuthPopup->SetOwner(&GetPublic());
4567 r = __pAuthPopup->ShowAndWait(modalResult);
4568 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4573 __pAuthPopup.reset();
4581 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4583 result r = E_SUCCESS;
4585 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4586 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4588 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4589 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4591 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4593 int modalResult = 0;
4595 __pCertConfirmPopup->SetOwner(&GetPublic());
4597 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4598 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4600 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4602 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4606 if (__pCertConfirmPopup.get())
4608 __pCertConfirmPopup.reset();
4616 _WebImpl::ShowPromptPopup(String msg, String defVal)
4618 result r = E_SUCCESS;
4620 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4621 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4623 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode());
4624 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4626 __pPromptPopup = std::move(pPromptPopup);
4628 __pPromptPopup->SetOwner(&GetPublic());
4630 r = __pPromptPopup->ShowPopup();
4631 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4636 __pPromptPopup.reset();
4644 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4646 result r = E_SUCCESS;
4648 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4649 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4651 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
4652 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4654 pUserConfirmPopup->SetOwner(&GetPublic());
4656 int modalResult = 0;
4658 switch(userConfirmMode)
4660 case USER_CONTENT_HANDLER:
4662 __pContentHandlerConfirmPopup.reset();
4664 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4666 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4667 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4670 case USER_PROTOCOL_HANDLER:
4672 __pProtocolHandlerConfirmPopup.reset();
4674 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4676 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4677 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4680 case USER_CONFIRM_APP_CACHE:
4682 __pAppCacheConfirmPopup.reset();
4684 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4686 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4687 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4690 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4692 __pDbQuotaConfirmPopup.reset();
4694 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4696 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4697 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4700 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4702 __pLocalFsQuotaConfirmPopup.reset();
4704 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4706 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4707 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4710 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4712 __pIndexedDbQuotaConfirmPopup.reset();
4714 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4716 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4717 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4729 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4731 result r = E_SUCCESS;
4733 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4734 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4736 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
4737 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4739 pUserConfirmPopup->SetOwner(&GetPublic());
4741 switch(userConfirmMode)
4743 case USER_CONFIRM_USERMEDIA:
4745 __pUserMediaConfirmPopup.reset();
4747 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4749 r = __pUserMediaConfirmPopup->ShowPopup();
4750 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4752 __pUserMediaConfirmPopup.release();
4755 case USER_CONFIRM_GEOLOCATION:
4757 __pGeolocationConfirmPopup.reset();
4759 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4761 r = __pGeolocationConfirmPopup->ShowPopup();
4762 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4764 __pGeolocationConfirmPopup.release();
4767 case USER_CONFIRM_NOTIFICATION:
4769 __pNotificationConfirmPopup.reset();
4771 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4773 r = __pNotificationConfirmPopup->ShowPopup();
4774 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4776 __pNotificationConfirmPopup.release();
4779 case USER_SCRIPT_ALERT:
4781 __pScriptAlertConfirmPopup.reset();
4783 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4785 r = __pScriptAlertConfirmPopup->ShowPopup();
4786 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4788 __pScriptAlertConfirmPopup.release();
4803 _WebImpl::GetParentFormCore(_Control* pControlCore)
4806 _Form* pFormCore = null;
4808 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4809 if (!pParentControlCore)
4814 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4820 return GetParentFormCore(pParentControlCore);
4825 _WebImpl::OnFocusGained(const _ControlImpl& source)
4832 _WebImpl::OnFocusLost(const _ControlImpl& source)
4834 if(IsKeypadVisible() == true)
4836 SetKeypadOpened(true);
4838 SetKeypadVisibleState(false);
4841 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4848 _WebImpl::HasValidNativeNode(void) const
4850 if (__pWebCore && __pWebCore->GetWebNativeNode())
4860 _WebImpl::OnPreAttachedToMainTree(void)
4862 result r = E_SUCCESS;
4864 r = __pWebCore->InitializeWebNativeNode();
4865 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4867 r = InitializeSetting();
4868 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4870 r = _ContainerImpl::OnPreAttachedToMainTree();
4871 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4878 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4884 case _CONTROL_ROTATION_0:
4887 case _CONTROL_ROTATION_90:
4890 case _CONTROL_ROTATION_180:
4893 case _CONTROL_ROTATION_270:
4899 ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree);
4904 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4906 _ContainerImpl::OnChangeLayout(orientation);
4908 if (__pColorPicker.get())
4910 __pColorPicker->ChangeLayout(orientation);
4913 HideFormDataWindow();
4915 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4916 _WebNotification* pWebNotification = null;
4918 while (pEnum->MoveNext() == E_SUCCESS)
4920 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4921 pWebNotification->OnChangeLayout();
4927 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4929 if (IsVisible() == true)
4931 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4935 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4941 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4943 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
4947 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4948 __pCertConfirmPopup.reset();
4950 case ID_PROMPT_POPUP_CLOSE:
4951 __pPromptPopup.reset();
4953 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
4954 __pUserMediaConfirmPopup.reset();
4956 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
4957 __pGeolocationConfirmPopup.reset();
4959 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
4960 __pNotificationConfirmPopup.reset();
4962 case ID_USER_SCRIPT_ALERT_CLOSE:
4963 __pScriptAlertConfirmPopup.reset();
4972 _WebImpl::GetDownloadHandler(void) const
4974 return __pWebDownloadHandler.get();
4979 _WebImpl::HideColorPicker(void)
4981 __pColorPicker.reset();
4988 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4990 result r = E_SUCCESS;
4992 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4993 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4995 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4997 r = pColorHadler->Construct(colorVal, this);
4998 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5000 __pColorPicker = std::move(pColorHadler);
5002 r = __pColorPicker->ShowPopup();
5003 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5007 color = __pColorPicker->GetColor();
5013 __pColorPicker.reset();
5021 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
5023 result r = E_SUCCESS;
5025 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
5026 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5028 r = pInputPicker->Construct(String(inputValue), inputType, this);
5029 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5031 __pDatePicker = std::move(pInputPicker);
5033 r = __pDatePicker->ShowPopup();
5034 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5038 dateStr = __pDatePicker->GetDate();
5044 __pDatePicker.reset();
5052 _WebImpl::GetInstance(Web* pWeb)
5054 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5059 _WebImpl::GetInstance(const Web* pWeb)
5061 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5066 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5068 int checkReturn = 0;
5070 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5073 if( checkmime == true)
5075 table = CUSTOM_CONTENT_TABLE_NAME;
5079 table = CUSTOM_PROTOCOL_TABLE_NAME;
5082 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5083 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5084 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5086 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5088 result r = db.Construct(handlerPath, "r+", null);
5089 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5091 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"'"));
5092 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5096 r = pEnum->MoveNext();
5097 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5098 r = pEnum->GetIntAt(0, checkReturn);
5099 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5111 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5115 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5118 if( checkmime == true)
5120 table = CUSTOM_CONTENT_TABLE_NAME;
5124 table = CUSTOM_PROTOCOL_TABLE_NAME;
5127 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5128 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5129 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5131 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5133 result r = db.Construct(handlerPath, "r+", null);
5134 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5136 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"'"));
5137 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5141 r = pEnum->MoveNext();
5142 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5143 r = pEnum->GetIntAt(0, checkId);
5144 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5146 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5147 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5149 r = pDeleteStmt->BindInt(0, checkId);
5150 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5152 db.BeginTransaction();
5154 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5156 db.CommitTransaction();
5163 const Tizen::Base::String
5164 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5166 if (originUri == L"" || currentUri == L"")
5171 result r = E_SUCCESS;
5174 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5175 String originReplace(originUri);
5176 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5180 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5181 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5183 r = currentUri.SubString(0, found + 1, baseUri);
5184 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5186 r = db.Construct(handlerPath, "r+", null);
5187 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5189 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5190 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5194 while (pEnum->MoveNext() == E_SUCCESS)
5199 String originScheme;
5201 r = pEnum->GetStringAt(0, protocol);
5202 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5204 r = pEnum->GetStringAt(1, queryUrl);
5205 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5207 r = pEnum->GetIntAt(2, allow);
5208 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5215 String protocolScheme(protocol + L":");
5217 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5218 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5220 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5222 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5224 r = originReplace.Replace(originScheme, "");
5225 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5227 queryUrl.Replace("%s", originReplace, 0);
5228 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5240 const Tizen::Base::String
5241 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5243 if (originUri == L"" || currentUri == L"" || mime == L"")
5248 result r = E_SUCCESS;
5251 String originUrlStr = originUri;
5252 const String replaceStr = L"%s";
5254 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5255 String table(CUSTOM_CONTENT_TABLE_NAME);
5259 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5260 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5262 r = currentUri.SubString(0, found + 1, baseUri);
5263 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5265 r = db.Construct(handlerPath, "r+", null);
5266 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5268 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5272 r = pEnum->MoveNext();
5273 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5274 r = pEnum->GetIntAt(0, allow);
5275 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5276 r = pEnum->GetStringAt(1, contentUrl);
5277 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5285 if (contentUrl != L"")
5287 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5288 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5300 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5302 __pFormDataList = pFormDataList;
5307 _WebImpl::IsFormDataWindowVisible(void) const
5309 return __isFormDataVisible;
5314 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5316 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5318 if (__isFormDataVisible)
5320 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5321 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5325 __pFormDataWindow.reset();
5327 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5328 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5330 result r = pFormDataWindow->Construct(rect, this, pWebView);
5331 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5333 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5334 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5336 r = pFormDataWindow->LaunchFormDataWindow();
5337 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5339 __pFormDataWindow = std::move(pFormDataWindow);
5340 __isFormDataVisible = true;
5348 _WebImpl::HideFormDataWindow(bool delWindow)
5352 __pFormDataWindow.reset();
5355 __isFormDataVisible = false;
5360 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5362 __webNotificationList.Remove(*pWebNotification);
5367 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5369 __webNotificationList.Add(pWebNotification);
5374 _WebImpl::OnDownloadCompleted(RequestId reqId, const String &path)
5376 _ContentManagerImpl::ScanFile(path);
5380 }}} // Tizen::Web::Controls