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_Evas.h>
25 #include <elm_config.h>
28 #include <ewk_popup_menu_item.h>
29 #include <libsoup/soup-status.h>
31 #include <FAppAppControl.h>
32 #include <FAppIAppControlListener.h>
33 #include <FBaseColAllElementsDeleter.h>
34 #include <FBaseColHashMapT.h>
35 #include <FBaseRtMutex.h>
36 #include <FBaseRtMutexGuard.h>
37 #include <FBaseSysLog.h>
38 #include <FBaseUtilUri.h>
39 #include <FCntDownloadRequest.h>
40 #include <FGrpColor.h>
41 #include <FGrpPoint.h>
42 #include <FGrpRectangle.h>
43 #include <FIoDbEnumerator.h>
44 #include <FIoDbStatement.h>
46 #include <FMediaImage.h>
47 #include <FMediaImageTypes.h>
48 #include <FNetHttpHttpHeader.h>
49 #include <FUiControl.h>
50 #include <FUiCtrlKeypad.h>
51 #include <FWebCtrlHitElementResult.h>
52 #include <FWebCtrlITextSearchListener.h>
53 #include <FWebCtrlIWebDownloadListener.h>
54 #include <FWebCtrlIWebUiEventListener.h>
55 #include <FWebCtrlIWebKeypadEventListener.h>
56 #include <FWebCtrlIJavaScriptBridge.h>
57 #include <FWebCtrlPageNavigationList.h>
58 #include <FWebCtrlAuthenticationChallenge.h>
59 #include <FWebCtrlWeb.h>
60 #include <FWebCtrlWebSetting.h>
61 #include <FWebHistoryItem.h>
62 #include <FWebJsonJsonObject.h>
63 #include <FWebJsonJsonParser.h>
64 #include <FWebJsonJsonString.h>
65 #include <FApp_AppControlImpl.h>
66 #include <FApp_AppControlManager.h>
67 #include <FApp_AppInfo.h>
68 #include <FApp_AppManagerImpl.h>
69 #include <FBase_StringConverter.h>
70 #include <FCnt_DownloadManagerImpl.h>
71 #include <FGrp_CoordinateSystem.h>
72 #include <FIo_DatabaseImpl.h>
73 #include <FIo_NormalFile.h>
74 #include <FUi_Control.h>
75 #include <FUi_EcoreEvasMgr.h>
76 #include <FUi_EcoreEvas.h>
77 #include <FUi_ResourceSizeInfo.h>
78 #include <FUi_Window.h>
79 #include <FUiAnim_EflNode.h>
80 #include <FUiAnim_VisualElement.h>
81 #include <FUiCtrl_FooterImpl.h>
82 #include <FUiCtrl_Form.h>
83 #include "FWeb_HistoryItemImpl.h"
84 #include "FWebCtrl_AppControlListener.h"
85 #include "FWebCtrl_AuthConfirmPopup.h"
86 #include "FWebCtrl_AuthenticationChallengeImpl.h"
87 #include "FWebCtrl_GeolocationConfirmPopup.h"
88 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
89 #include "FWebCtrl_HitElementResultImpl.h"
90 #include "FWebCtrl_InputPickerPopup.h"
91 #include "FWebCtrl_PageNavigationListImpl.h"
92 #include "FWebCtrl_PromptPopup.h"
93 #include "FWebCtrl_SelectBox.h"
94 #include "FWebCtrl_Utility.h"
95 #include "FWebCtrl_Web.h"
96 #include "FWebCtrl_WebDataHandler.h"
97 #include "FWebCtrl_WebEvent.h"
98 #include "FWebCtrl_WebEventArg.h"
99 #include "FWebCtrl_WebImpl.h"
100 #include "FWebCtrl_WebPresenter.h"
101 #include "FWebCtrl_WebSettingImpl.h"
104 using namespace Tizen::App;
105 using namespace Tizen::Base;
106 using namespace Tizen::Base::Collection;
107 using namespace Tizen::Base::Runtime;
108 using namespace Tizen::Base::Utility;
109 using namespace Tizen::Content;
110 using namespace Tizen::Graphics;
111 using namespace Tizen::Io;
112 using namespace Tizen::Media;
113 using namespace Tizen::Net::Http;
114 using namespace Tizen::Ui;
115 using namespace Tizen::Ui::Animations;
116 using namespace Tizen::Ui::Controls;
117 using namespace Tizen::Web::Json;
120 namespace Tizen { namespace Web { namespace Controls
124 static const char WEB_CTRL[] = "webcontrol";
125 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
128 static const float MIN_ZOOM_LEVEL = 0.3;
129 static const float MAX_ZOOM_LEVEL = 2;
132 static const int REDIRECTION_HEADER_GROUP = 300;
135 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
138 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
139 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
143 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
145 result r = E_SUCCESS;
147 String key(reinterpret_cast< const char* >(pKey));
148 String value(reinterpret_cast< char* >(pValue));
150 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
152 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
153 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
160 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
162 result r = E_SUCCESS;
164 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
165 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
166 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
168 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
170 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
171 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
173 pAttrValue.release();
179 void FreeCharArray(void* pData)
181 delete[] reinterpret_cast<char*>(pData);
186 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
188 result r = E_SUCCESS;
190 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
191 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
192 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
193 SysTryReturn(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
195 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
196 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
197 pErrorCode.release();
199 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
200 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
201 pErrorDescription.release();
203 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
204 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
212 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
214 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
216 result r = E_SUCCESS;
218 String msg(pMessage);
220 MessageBox messageBox;
221 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OK);
222 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
225 r = messageBox.ShowAndWait(modalResult);
226 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
228 ewk_view_javascript_alert_reply(pView);
235 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
237 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
239 result r = E_SUCCESS;
241 String msg(pMessage);
243 MessageBox messageBox;
244 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
245 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
248 r = messageBox.ShowAndWait(modalResult);
249 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
251 if (modalResult == MSGBOX_RESULT_OK)
253 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
257 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
265 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
267 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
269 result r = E_SUCCESS;
271 String msg(pMessage);
272 String defVal(pDefaultValue);
274 int modalResult = -1;
275 _PromptPopup pPromptPopup;
277 r = pPromptPopup.Construct(msg, defVal);
278 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
280 pPromptPopup.ShowAndWait(modalResult);
284 std::unique_ptr<char[]> pResult(_StringConverter::CopyToCharArrayN(pPromptPopup.GetPromptText()));
285 SysTryReturn(NID_WEB_CTRL, pResult.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
287 ewk_view_javascript_prompt_reply(pView, pResult.get());
291 ewk_view_javascript_prompt_reply(pView, null);
299 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
301 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
302 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
303 SysAssertf(pImpl && pPolicy, "Failed to request");
305 SysLog(NID_WEB_CTRL, "url : %s, pem : %s, error : %d", ewk_certificate_policy_decision_url_get(pPolicy), ewk_certificate_policy_decision_certificate_pem_get(pPolicy), ewk_certificate_policy_decision_error_get(pPolicy));
307 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
309 if (pImpl->GetLoadingListener())
311 // ToDo : If certificate check works properly, remove annotation.
312 // r = FireLoadingErrorOccurredEvent(pImpl, 999, "Invalid certificate.");
313 // SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
319 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
321 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
322 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
323 SysAssertf(pImpl && pChallenge, "Failed to request");
325 result r = E_SUCCESS;
327 r = pImpl->HttpAuthenticationRequested(pChallenge);
328 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
333 ewk_auth_challenge_credential_cancel(pChallenge);
334 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
339 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
341 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
342 SysAssertf(pImpl , "Failed to request");
344 if (pImpl->GetLoadingListener())
346 result r = E_SUCCESS;
348 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
349 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
351 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
352 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
359 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
361 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
362 Ewk_Geolocation_Permission_Data* pPermissionData = reinterpret_cast< Ewk_Geolocation_Permission_Data* >(pEventInfo);
363 SysAssertf(pImpl && pPermissionData, "Failed to request");
365 Ewk_Geolocation_Permission_Request permissionRequest = ewk_geolocation_permission_request_get(pPermissionData);
367 if (pImpl->GetSetting().IsGeolocationEnabled())
369 result r = E_SUCCESS;
371 std::unique_ptr<DbEnumerator> pEnum;
373 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + GEOLOCATION_DIRECTORY_PATH + GEOLOCATION_DB_NAME);
374 String table(GEOLOCATION_TABLE_NAME);
377 const Ewk_Security_Origin* pOrigin = ewk_geolocation_permission_request_origin_get(pPermissionData);
378 String origin = _GeolocationPermissionManagerImpl::CreateOrigin(pOrigin);
380 r = db.Construct(geolocationPath, "r", null);
381 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
383 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
386 r = pEnum->MoveNext();
387 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
390 r = pEnum->GetIntAt(0, permission);
391 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
393 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
395 ewk_geolocation_permission_request_allow_set(permissionRequest, static_cast < Eina_Bool >(permission));
399 r = pImpl->ShowGeolocationPopup(pPermissionData);
400 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
407 ewk_geolocation_permission_request_allow_set(permissionRequest, EINA_FALSE);
412 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
414 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
415 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
416 SysAssertf(pImpl && pPolicy, "Failed to request");
418 String url(ewk_policy_decision_url_get(pPolicy));
419 SysLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
421 if (url == L"about:blank")
423 ewk_policy_decision_use(pPolicy);
427 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
428 && !pImpl->IsRedirectRequested())
430 if (pImpl->GetTextSearchListener())
432 pImpl->DisableAsyncSearch();
435 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
436 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
438 switch (ewkNavigationType)
440 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
441 navigationType = WEB_NAVIGATION_LINK_CLICKED;
443 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
444 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
446 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
447 navigationType = WEB_NAVIGATION_BACKFORWARD;
449 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
450 navigationType = WEB_NAVIGATION_RELOAD;
452 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
453 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
455 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
456 navigationType = WEB_NAVIGATION_OTHER;
462 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
464 ewk_policy_decision_ignore(pPolicy);
470 String uriScheme(ewk_policy_decision_scheme_get(pPolicy));
471 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
473 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
475 ewk_policy_decision_ignore(pPolicy);
477 result r = E_SUCCESS;
479 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
481 if (uriScheme == L"rtsp")
483 eventType = WEB_EVENT_REQUEST_RTSP;
485 else if (uriScheme == L"mailto")
487 eventType = WEB_EVENT_REQUEST_EMAIL;
489 else if (uriScheme == L"tel")
491 eventType = WEB_EVENT_REQUEST_TEL;
493 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
495 eventType = WEB_EVENT_REQUEST_SMS;
497 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
499 eventType = WEB_EVENT_REQUEST_MMS;
502 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
503 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
505 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
506 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
512 ewk_policy_decision_use(pPolicy);
517 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
519 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
520 SysAssertf(pImpl, "Failed to request");
522 if (pImpl->GetLoadingListener())
524 result r = E_SUCCESS;
526 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
527 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
529 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
530 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
537 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
539 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
540 char* pTitle = reinterpret_cast< char* >(pEventInfo);
541 SysAssertf(pImpl, "Failed to request");
543 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
545 if (pImpl->GetLoadingListener())
547 result r = E_SUCCESS;
549 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
550 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
551 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
553 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
554 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
555 pPageTitle.release();
557 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
558 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
565 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
567 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
568 double* pProgress = reinterpret_cast< double* >(pEventInfo);
569 SysAssertf(pImpl, "Failed to request");
571 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
573 if (pImpl->GetLoadingListener())
575 result r = E_SUCCESS;
577 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
578 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
579 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
581 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
582 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
583 pProgressPercentage.release();
585 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
586 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
593 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
595 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
596 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
597 SysAssertf(pImpl && pPolicy, "Failed to request");
599 result r = E_SUCCESS;
601 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
602 int code = ewk_policy_decision_response_status_code_get(pPolicy);
603 String mime(ewk_policy_decision_response_mime_get(pPolicy));
604 SysLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
606 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
607 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
609 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
611 DecisionPolicy policy;
612 HttpHeader httpHeader;
614 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
616 pImpl->SetRedirectRequested(true);
620 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
621 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
623 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
624 pImpl->SetPolicyDecision(policy);
627 switch (pImpl->GetPolicyDecision())
629 case WEB_DECISION_CONTINUE:
631 if (pImpl->IsMimeSupported(mime) || mime == L"")
638 SysLog(NID_WEB_CTRL, "Lauch native app to handle the mime");
640 ewk_policy_decision_ignore(pPolicy);
642 AppControl* pAppControl = null;
643 _SelectBox selectBox;
645 int selectedIndex = 0;
647 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
651 appCount = pList->GetCount();
654 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
655 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
657 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
658 for (int i = 0; i < appCount; i++)
660 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
661 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
663 String text = pAppControl->GetAppName();
664 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
666 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
668 selectBox.ShowAndWait(selectedIndex);
670 if (selectedIndex == 0) //download
673 DownloadRequest request(pUrl);
675 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
676 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
678 r = pManagerImpl->Start(request, reqId);
679 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
681 else if (selectedIndex != -1) // -1 for cancel
684 String pathVal(pUrl);
687 r = dataList.Construct();
688 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
690 r = dataList.Add(path, pathVal);
691 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
693 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
694 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
696 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
697 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
699 r = pAcImpl->Start(null, null, &dataList, null);
700 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
707 case WEB_DECISION_DOWNLOAD:
709 ewk_policy_decision_ignore(pPolicy);
711 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
712 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
714 Ewk_Context* pContext = ewk_view_context_get(pView);
715 SysAssertf(pContext, "Failed to get webkit instance.");
717 pDownloadHandler->StartDownload(pUrl);
721 case WEB_DECISION_IGNORE:
723 ewk_policy_decision_ignore(pPolicy);
733 ewk_policy_decision_use(pPolicy);
738 ewk_policy_decision_ignore(pPolicy);
743 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
745 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
746 SysAssertf(pImpl, "Failed to request");
748 if (pImpl->IsRedirectRequested())
750 pImpl->SetRedirectRequested(false);
753 if (pImpl->IsLoadingErrorOccurred())
755 pImpl->SetLoadingErrorOccurred(false);
756 evas_object_smart_callback_call(pView, "load,finished", NULL);
762 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
764 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
765 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
766 SysAssertf(pImpl && pErrorData, "Failed to request");
768 int code = ewk_error_code_get(pErrorData);
769 const char* pDescription = ewk_error_description_get(pErrorData);
771 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
773 pImpl->SetLoadingErrorOccurred(true);
776 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
778 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
781 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
782 evas_object_smart_callback_call(pView, "load,stop", NULL);
786 if (pImpl->GetLoadingListener())
788 result r = E_SUCCESS;
790 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
791 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
799 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
801 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
802 SysAssertf(pImpl, "Failed to request");
804 if (pImpl->GetLoadingListener())
806 result r = E_SUCCESS;
808 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
809 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
811 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
812 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
820 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
822 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
823 SysAssertf(pImpl, "Failed to request");
825 if (pImpl->GetLoadingListener())
827 result r = E_SUCCESS;
829 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
830 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
832 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
833 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
841 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
843 evas_object_focus_set(pView, EINA_FALSE);
848 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
850 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
851 SysAssertf(pUrl && pImpl != null, "Failed to request");
853 SysLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
858 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
860 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
861 SysAssertf(pImpl, "Failed to request");
863 if (pImpl->GetUiEventListener())
865 result r = E_SUCCESS;
867 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED));
868 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
870 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
871 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
878 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
880 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
881 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
882 SysAssertf(pParentImpl && pChildView, "Failed to request");
884 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
887 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
890 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
891 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
893 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
894 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
901 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
903 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
904 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
905 SysAssertf(pChildImpl && pParentImpl, "Failed to request");
907 if (pParentImpl->GetUiEventListener())
909 result r = E_SUCCESS;
911 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED));
912 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
914 r = pChildImpl->GetWebEvent()->FireAsync(*pEventArg.get());
915 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
922 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
924 Eina_Bool ret = EINA_FALSE;
925 Eina_List* pSelectedFileNames = null;
926 String isMultipleSelection(L"single");
930 isMultipleSelection.Append(L"multiple");
933 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
934 SysTryCatch(NID_WEB_CTRL, pMediaListener.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
937 int itemCount = eina_list_count(pAcceptTypes);
938 String fileType = L"all";
942 String item((char*)eina_list_nth(pAcceptTypes, 0));
943 if (item.StartsWith("image/",0))
947 else if (item.StartsWith("audio/",0))
951 else if (item.StartsWith("video/",0))
958 result r = dataList.Construct();
959 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
961 String mode(L"selectionType");
962 r = dataList.Add(mode, isMultipleSelection);
963 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
965 String type(L"type");
966 r = dataList.Add(type, fileType);
967 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
969 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
970 SysTryCatch(NID_WEB_CTRL, pMediaAppControl.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
972 _AppControlImpl* pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl);
973 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
974 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
978 if (pMediaListener->IsSelectionCompleted())
980 const ArrayList* pSelectedFiles = pMediaListener->GetSelectedFiles();
981 SysTryCatch(NID_WEB_CTRL, pSelectedFiles, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
983 int fileCount = pSelectedFiles->GetCount();
985 for (int i = 0; i < fileCount; i++)
987 String* pFile = (String*)pSelectedFiles->GetAt(i);
988 SysTryCatch(NID_WEB_CTRL, pFile, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
990 std::unique_ptr<ByteBuffer> pByteBuf(StringUtil::StringToUtf8N(*pFile));
991 SysTryCatch(NID_WEB_CTRL, pByteBuf.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
993 pSelectedFileNames = eina_list_append(pSelectedFileNames, strdup((const char*)pByteBuf->GetPointer()));
1000 ecore_main_loop_iterate();
1003 ewk_view_open_panel_reply(pView, pSelectedFileNames, ret);
1008 ewk_view_open_panel_reply(pView, null, ret);
1009 eina_list_free(pSelectedFileNames);
1015 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1017 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1018 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1019 SysAssertf(pImpl && pJsonText, "Failed to request");
1021 result r = E_SUCCESS;
1023 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1025 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1026 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1028 r = pEventArg->Construct(pJsonText);
1029 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1031 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1032 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1033 pEventArg.release();
1038 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1040 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1041 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1042 SysAssertf(pImpl && pEinaRect, "Failed to request");
1044 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1046 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1047 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1049 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1051 if (rect.height == 0)
1056 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1057 SysAssertf(pFormCore != null, "Failed to get FormCore");
1059 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1061 pImpl->SetFooterVisibleState(true);
1062 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1065 if (pImpl->GetWebKeypadEventListener())
1067 if (pImpl->IsKeypadVisible() == true)
1069 if ((pImpl->GetPreviousOrientation() == pFormCore->GetOrientation()) && (pImpl->GetKeypadHeight() != rect.height))
1071 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1072 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1077 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1078 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1081 pImpl->SetKeypadVisibleState(true);
1082 pImpl->SetPreviousOrientation(pFormCore->GetOrientation());
1083 pImpl->SetKeypadHeight(rect.height);
1087 result r = pImpl->SetFullScreenKeypad();
1088 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1094 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1096 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1097 SysAssertf(pImpl, "Failed to request");
1099 if (pImpl->GetWebKeypadEventListener())
1101 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1107 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1109 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1110 SysAssertf(pImpl, "Failed to request");
1112 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1113 SysAssertf(pFormCore != null, "Failed to get FormCore");
1115 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1117 pImpl->SetFooterVisibleState(false);
1118 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1121 pFormCore->DeflateClientRectHeight(0);
1123 if (pImpl->GetWebKeypadEventListener())
1125 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1128 pImpl->SetKeypadVisibleState(false);
1133 OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info)
1135 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1136 SysAssertf(pImpl, "Failed to request");
1138 if (pImpl->IsKeypadOpened() == true)
1140 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1141 SysAssertf(pWebCore, "Failed to get Web core object");
1143 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1145 pImpl->SetKeypadOpened(false);
1151 OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo)
1153 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1154 SysAssertf(pImpl, "Failed to request");
1156 if (pImpl->IsKeypadOpened() == true)
1158 pImpl->SetKeypadOpened(false);
1164 OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha)
1166 SysAssertf(pSmartData, "invalid smartdata");
1167 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1168 SysAssertf(pWebImpl, "Failed to get Impl");
1170 result r = E_SUCCESS;
1172 if (pWebImpl->GetColorpicker())
1179 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1180 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1182 byte r1, g1, b1, a1;
1183 color.GetColorComponents(r1, g1, b1, a1);
1184 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1191 OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData)
1193 SysAssertf(pSmartData, "invalid smartdata");
1195 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1196 SysAssertf(pWebImpl, "Failed to get Impl");
1198 return pWebImpl->HideColorPicker();
1203 OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1205 SysAssertf(pSmartData, "Failed to request");
1206 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1207 SysAssertf(pWebImpl, "Failed to get Impl");
1209 result r = E_SUCCESS;
1211 if (pWebImpl->GetDatepicker())
1213 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1220 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1221 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1223 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1224 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1226 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1233 OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1235 SysAssertf(pSmartData, "Failed to request");
1237 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1238 SysAssertf(pWebImpl, "Failed to get Impl");
1240 result r = E_SUCCESS;
1242 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
1243 SysTryReturn(NID_WEB_CTRL, pSelectBox.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1245 //Create list required for selectBox
1246 int itemCount = eina_list_count(pItems);
1247 SysTryReturn(NID_WEB_CTRL, itemCount > 0, EINA_FALSE , E_SYSTEM, "[%s] ItemCount is invalid.", GetErrorMessage(E_SYSTEM));
1249 r = pSelectBox->Construct(false, L"", itemCount, pSmartData->self);
1250 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1252 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
1253 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1255 pWebImpl->SetSelectBox(pSelectBox.release());
1257 pWebImpl->GetSelectBox()->Show();
1264 OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData)
1266 SysAssertf(pSmartData, "invalid smartdata");
1268 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1269 SysAssertf(pWebImpl, "Failed to get Impl");
1271 Eina_Bool ret = EINA_TRUE;
1273 _SelectBox* pSelectBox = pWebImpl->GetSelectBox();
1277 pWebImpl->DeleteSelectBox();
1289 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1291 SysAssertf(pSmartData, "invalid smartdata");
1293 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1294 SysAssertf(pWebImpl, "Failed to get Impl");
1296 _SelectBox* pSelectBox = pWebImpl->GetSelectBox();
1298 Eina_Bool ret = EINA_FALSE;
1302 result r = pSelectBox->UpdateList(pItems, selectedIndex, true, false);
1303 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1313 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1315 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1316 SysAssertf(pPresenter && !pError, "Failed to request");
1318 bool ret = EINA_TRUE;
1322 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1324 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1328 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1337 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1339 pPresenter->EndAsyncProcess(ret);
1344 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1346 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1347 SysAssertf(pPresenter, "Failed to request");
1349 String result(pResult);
1350 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1352 pPresenter->EndAsyncProcess(result);
1357 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
1359 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1360 SysAssertf(pImpl, "Failed to request");
1362 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
1363 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
1365 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
1369 pWebPresenter->EndAsyncProcess(*pTotalCount);
1373 if (pImpl->GetTextSearchListener())
1375 result r = E_SUCCESS;
1379 if (*pTotalCount > 0)
1381 ordinal = pImpl->GetAsyncSearchOrdinal();
1382 pImpl->SetAsyncSearchResult(*pTotalCount);
1385 if (pImpl->GetPendingAsyncSearchCount() > 0)
1390 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
1391 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
1392 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
1393 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1395 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
1396 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1399 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
1400 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1403 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1404 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1405 pEventArg.release();
1411 class _JsBridgeHashCodeProvider
1412 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
1415 _JsBridgeHashCodeProvider(){}
1416 virtual ~_JsBridgeHashCodeProvider(void) {}
1419 int GetHashCode(const Tizen::Base::String& obj) const
1421 return obj.GetHashCode();
1427 //Comparer implementation
1428 class _JsBridgeComparer
1429 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
1432 _JsBridgeComparer(){}
1433 virtual ~_JsBridgeComparer(void) {}
1436 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
1453 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
1454 : _ContainerImpl(pWeb, pCore)
1455 , __isFooterVisible(false)
1456 , __isKeypadVisible(false)
1457 , __isKeypadOpened(false)
1458 , __isLoadingErrorOccurred(false)
1459 , __isRedirectRequested(false)
1462 , __pUserLoadingListener(null)
1463 , __pUserUiListener(null)
1464 , __pUserKeypadEventListener(null)
1465 , __pTextSearchListener(null)
1467 , __pWebSetting(null)
1468 , __pJsBridgeList(null)
1469 , __pJsProvider(null)
1470 , __pJsComparer(null)
1471 , __pWebDownloadHandler(null)
1473 , __pAuthChallenge(null)
1474 , __pAuthPopup(null)
1475 , __pGeolocationPopup(null)
1476 , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
1477 , __pSelectBox(null)
1478 , __pDatePicker(null)
1479 , __pColorPicker(null)
1480 , __policy(WEB_DECISION_CONTINUE)
1482 __textSearch.__searchAll = false;
1483 __textSearch.__searchForward = true;
1484 __textSearch.__caseSensitive = false;
1485 __textSearch.__pending = 0;
1486 __textSearch.__currentIndex = 1;
1487 __textSearch.__totalCount -1;
1488 __textSearch.__text = L"";
1492 _WebImpl::~_WebImpl()
1494 RemoveEventListenerCallback();
1498 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
1500 result r = E_SUCCESS;
1502 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
1503 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1505 _Web* pCore = _Web::CreateWebN();
1506 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1508 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
1510 r = CheckConstruction(pCore, pImpl);
1511 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1513 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
1514 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1516 r = pImpl->Construct();
1517 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1529 _WebImpl::Construct(void)
1531 result r = E_SUCCESS;
1533 r = __mutex.Create();
1534 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1536 r = __textSearch.__searchQueue.Construct();
1537 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1539 __pWebSetting = std::unique_ptr<WebSetting>(new (std::nothrow) WebSetting());
1540 SysTryReturn(NID_WEB_CTRL, __pWebSetting.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1542 r = InitJsBridgeList();
1543 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1546 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1548 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
1549 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
1551 __pWebCore->SetWebSettingImpl(_WebSettingImpl::GetInstance(__pWebSetting.get()));
1558 _WebImpl::InitializeSetting(void)
1560 result r = E_SUCCESS;
1562 r = SetSetting(*__pWebSetting.get());
1563 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1565 SetCookieEnabled(_WebSettingImpl::GetInstance(__pWebSetting.get())->IsCookieEnabled());
1566 SetPrivateBrowsingEnabled(_WebSettingImpl::GetInstance(__pWebSetting.get())->IsPrivateBrowsingEnabled());
1567 SetZoomLevel(_WebSettingImpl::GetInstance(__pWebSetting.get())->GetZoomLevel());
1569 SetEventListenerCallback();
1571 _Form* pFormCore = GetParentFormCore(dynamic_cast< _Control* >(&this->GetCore()));
1572 SysAssertf(pFormCore != null, "Failed to get FormCore");
1574 SetPreviousOrientation(pFormCore->GetOrientation());
1581 _WebImpl::IsLayoutable(void) const
1588 _WebImpl::InitWebEvent(void)
1590 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
1591 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1593 return __pWebEvent->Construct(*this);
1598 _WebImpl::GetWebEvent(void) const
1600 return __pWebEvent.get();
1605 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
1607 Eina_Hash* pHttpHeader = null;
1609 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
1610 if (pFieldNameList.get())
1612 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
1613 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1615 int count = pFieldNameList->GetCount();
1617 for (int i = 0; i < count; i++)
1619 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
1620 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1622 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
1623 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1625 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
1626 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1628 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
1630 Eina_Bool ret = false;
1632 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
1633 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1635 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
1636 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1638 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
1639 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1646 eina_hash_free(pHttpHeader);
1653 _WebImpl::LoadUrl(const String& url) const
1655 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
1656 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1658 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
1665 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
1667 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
1668 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1670 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
1672 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
1674 eina_hash_free(pHttpHeader);
1681 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
1684 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
1685 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1687 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
1689 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
1691 eina_hash_free(pHttpHeader);
1698 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
1700 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
1701 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
1702 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
1703 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1705 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
1712 _WebImpl::Pause(void)
1714 ewk_view_suspend(__pWebCore->GetWebNativeNode());
1719 _WebImpl::Resume(void)
1721 ewk_view_resume(__pWebCore->GetWebNativeNode());
1726 _WebImpl::SetSelectBox(_SelectBox* pSelectBox)
1728 __pSelectBox = std::unique_ptr<_SelectBox>(pSelectBox);
1733 _WebImpl::GetSelectBox(void)
1735 return __pSelectBox.get();
1740 _WebImpl::DeleteSelectBox(void)
1742 _SelectBox* pSelectBox = __pSelectBox.release();
1748 _WebImpl::GetDatepicker(void)
1750 _InputPickerPopup* pInputPicker =null;
1753 pInputPicker = __pDatePicker.get();
1755 return pInputPicker;
1760 _WebImpl::GetColorpicker(void)
1762 _InputPickerPopup* pInputPicker =null;
1765 pInputPicker = __pColorPicker.get();
1767 return pInputPicker;
1772 _WebImpl::CanGoBack(void) const
1774 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
1779 _WebImpl::CanGoForward(void) const
1781 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
1786 _WebImpl::GoBack(void) const
1788 ewk_view_back(__pWebCore->GetWebNativeNode());
1793 _WebImpl::GoForward(void) const
1795 ewk_view_forward(__pWebCore->GetWebNativeNode());
1800 _WebImpl::GetUrl(void) const
1802 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
1807 _WebImpl::GetTitle(void) const
1809 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
1814 _WebImpl::StopLoading(void) const
1816 ewk_view_stop(__pWebCore->GetWebNativeNode());
1821 _WebImpl::Reload(void) const
1823 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
1828 _WebImpl::EvaluateJavascriptN(const String& scriptCode) const
1830 if (scriptCode.GetLength())
1832 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
1833 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1835 _WebPresenter presenter;
1836 presenter.InitAsyncProcess();
1838 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, &presenter);
1840 Tizen::Base::String* pResult = new (std::nothrow) Tizen::Base::String(L"");
1841 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1842 presenter.WaitAsyncProcess(*pResult);
1852 _WebImpl::SetZoomLevel(float level)
1854 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);
1856 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
1863 _WebImpl::GetZoomLevel(void) const
1865 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
1869 const PageNavigationList*
1870 _WebImpl::GetBackForwardListN(void) const
1872 result r = E_SUCCESS;
1874 _PageNavigationListImpl* pNavigationListImpl = null;
1875 _HistoryItemImpl* pHistoryItemImpl = null;
1877 std::unique_ptr<PageNavigationList> pNavigationList;
1878 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
1881 int forwardCount = 0;
1886 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
1887 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
1889 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
1890 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
1892 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
1893 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1895 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
1896 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1898 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
1899 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1901 r = pHistoryList->Construct();
1902 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1904 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
1905 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
1906 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
1908 for (int i = -backCount; i < forwardCount + 1; i++)
1910 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
1911 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1913 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
1914 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1916 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
1917 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1919 url = ewk_history_item_uri_get(pEwkItem);
1920 title = ewk_history_item_title_get(pEwkItem);
1921 SysLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
1923 pHistoryItemImpl->SetHistoryItem(url, title);
1925 r = pHistoryList->Add(*pHistoryItem.get());
1926 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1927 pHistoryItem.release();
1930 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
1932 ewk_history_free(pEwkHistoryList);
1934 return pNavigationList.release();
1937 ewk_history_free(pEwkHistoryList);
1944 _WebImpl::AddCustomHeader(const HttpHeader& header)
1946 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
1947 if (pFieldNameList.get())
1949 int count = pFieldNameList->GetCount();
1950 for (int i = 0; i < count; i++)
1952 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
1953 SysTryReturn(NID_WEB_CTRL, pFieldName, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1955 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
1956 SysTryReturn(NID_WEB_CTRL, pKey.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1958 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
1959 SysTryReturn(NID_WEB_CTRL, pFieldValueEnum.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1961 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
1963 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
1964 SysTryReturn(NID_WEB_CTRL, pFieldValue, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1966 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
1967 SysTryReturn(NID_WEB_CTRL, pValue.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1969 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pKey.get(), pValue.get());
1978 _WebImpl::RemoveAllCustomHeaders(void)
1984 _WebImpl::SearchText(const String& text, bool searchForward)
1986 result r = E_SUCCESS;
1988 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
1992 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
1995 _WebPresenter presenter;
1996 presenter.InitAsyncProcess();
1998 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
1999 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2002 presenter.WaitAsyncProcess(result);
2004 return static_cast < bool >(result);
2009 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2011 result r = E_SUCCESS;
2013 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2017 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2020 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2021 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2028 _WebImpl::SearchNextAsync(bool searchForward)
2030 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2031 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2032 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2034 result r = E_SUCCESS;
2036 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2038 if (__textSearch.__caseSensitive)
2040 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2045 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2048 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2049 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2056 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2058 MutexGuard lock(__mutex);
2060 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2061 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2066 if (__textSearch.__searchAll)
2068 DisableAsyncSearch();
2070 __textSearch.__searchQueue.Enqueue(this);
2071 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2073 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2074 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2078 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2080 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2084 case SEARCH_ALL_ASYNC:
2085 __textSearch.__searchAll = true;
2086 __textSearch.__text = text;
2087 __textSearch.__searchForward = true;
2088 __textSearch.__caseSensitive = caseSensitive;
2089 __textSearch.__totalCount = -1;
2090 __textSearch.__currentIndex = 1;
2092 __textSearch.__searchQueue.Enqueue(this);
2093 __textSearch.__searchQueue.Enqueue(this);
2095 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2096 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2099 case SEARCH_NEXT_ASYNC:
2100 __textSearch.__searchForward = searchForward;
2102 CalculateAsyncSearchOrdinal();
2104 __textSearch.__searchQueue.Enqueue(this);
2106 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2118 _WebImpl::SetAsyncSearchResult(int totalCount)
2120 __textSearch.__totalCount = totalCount;
2125 _WebImpl::GetSearchPresenter(void)
2127 MutexGuard lock(__mutex);
2129 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2134 _WebImpl::GetPendingAsyncSearchCount(void) const
2136 return __textSearch.__searchQueue.GetCount();
2141 _WebImpl::CalculateAsyncSearchOrdinal(void)
2143 if (__textSearch.__searchForward)
2145 __textSearch.__currentIndex++;
2149 __textSearch.__currentIndex--;
2155 _WebImpl::GetAsyncSearchOrdinal(void) const
2157 return __textSearch.__currentIndex;
2162 _WebImpl::DisableAsyncSearch(void)
2164 __textSearch.__searchAll = false;
2169 _WebImpl::SetSetting(const WebSetting& setting)
2171 if (__pWebCore->GetWebNativeNode())
2173 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2174 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2175 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2177 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2178 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2180 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2182 switch (setting.GetCacheControl())
2184 case WEB_CACHE_VALIDATED:
2185 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2188 case WEB_CACHE_IGNORE:
2189 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2196 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2198 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2202 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2205 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2207 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2209 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2211 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2212 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2214 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2216 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2218 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2220 ewk_settings_show_ime_on_autofocus_set(pSettings, EINA_FALSE);
2223 __pWebSetting->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2224 __pWebSetting->SetCacheControl(setting.GetCacheControl());
2225 __pWebSetting->SetFontSize(setting.GetFontSize());
2226 __pWebSetting->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2227 __pWebSetting->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2228 __pWebSetting->SetInputStyle(setting.GetInputStyle());
2229 __pWebSetting->SetUserAgent(setting.GetUserAgent());
2230 __pWebSetting->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2231 __pWebSetting->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2232 __pWebSetting->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2239 _WebImpl::GetSetting(void) const
2241 return *__pWebSetting;
2245 const HitElementResult*
2246 _WebImpl::GetElementByPointN(const Point& point) const
2248 result r = E_SUCCESS;
2250 _HitElementResultImpl* pHitElementResultImpl = null;
2252 std::unique_ptr<HitElementResult> pHitElementResult;
2253 std::unique_ptr<Bitmap> pImage;
2254 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2256 Point absPoint(__pWebCore->GetAbsoluteCoordinate(point));
2258 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2259 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2261 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2262 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2263 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2264 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2265 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2267 SysLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2269 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2270 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2272 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2273 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2275 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
2281 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
2282 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
2283 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
2284 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
2286 r = buf.Construct(imageLength);
2287 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2289 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
2290 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2294 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
2295 // webkit support types such as ico and vp8 additionally
2296 if (strcmp(pExtension, "gif") == 0)
2298 format = IMG_FORMAT_GIF;
2300 else if (strcmp(pExtension, "jpg") == 0)
2302 format = IMG_FORMAT_JPG;
2304 else if (strcmp(pExtension, "png") == 0)
2306 format = IMG_FORMAT_PNG;
2308 else if (strcmp(pExtension, "bmp") == 0)
2310 format = IMG_FORMAT_BMP;
2314 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
2318 r = image.Construct();
2319 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2321 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
2322 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2327 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
2328 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2330 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
2331 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2333 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
2334 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2337 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
2339 ewk_hit_test_free(pEwkHitTest);
2341 return pHitElementResult.release();
2344 ewk_hit_test_free(pEwkHitTest);
2351 _WebImpl::IsLoading(void) const
2353 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
2355 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
2367 _WebImpl::GetTextFromBlock(void) const
2369 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
2374 _WebImpl::IsPrivateBrowsingEnabled(void) const
2376 if (__pWebCore->GetWebNativeNode() == null)
2378 return _WebSettingImpl::GetInstance(__pWebSetting.get())->IsPrivateBrowsingEnabled();
2381 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2382 SysAssertf(pSettings, "Failed to get webkit instance.");
2384 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
2389 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
2391 if (__pWebCore->GetWebNativeNode() == null)
2393 _WebSettingImpl::GetInstance(__pWebSetting.get())->SetPrivateBrowsingEnabled(enable);
2397 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2398 SysAssertf(pSettings, "Failed to get webkit instance.");
2400 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
2407 _WebImpl::ClearCache(void)
2409 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2410 SysAssertf(pContext, "Failed to get webkit instance.");
2412 ewk_context_cache_clear(pContext);
2417 _WebImpl::ClearCookie(void)
2419 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2420 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2421 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2423 ewk_cookie_manager_cookies_clear(pCookieManager);
2428 _WebImpl::IsCookieEnabled(void) const
2430 if (__pWebCore->GetWebNativeNode() == null)
2432 return _WebSettingImpl::GetInstance(__pWebSetting.get())->IsCookieEnabled();
2435 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2436 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2437 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2439 _WebPresenter presenter;
2440 presenter.InitAsyncProcess();
2442 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
2444 bool result = false;
2445 presenter.WaitAsyncProcess(result);
2452 _WebImpl::SetCookieEnabled(bool enable)
2454 if (__pWebCore->GetWebNativeNode() == null)
2456 _WebSettingImpl::GetInstance(__pWebSetting.get())->SetCookiEnabled(enable);
2461 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2462 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2463 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2467 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY);
2471 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
2472 ewk_cookie_manager_cookies_clear(pCookieManager);
2478 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
2480 result r = E_SUCCESS;
2482 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
2483 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2486 String fileExtension = File::GetFileExtension(filePath);
2487 int pathLength = filePath.GetLength();
2490 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
2492 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
2493 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
2494 r = filePath.SubString(0, index + 1, dirPath);
2495 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
2497 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
2498 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
2502 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
2504 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
2508 Evas_Coord contentsWidth;
2509 Evas_Coord contentsHeight;
2511 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
2512 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
2520 _WebImpl::IsMimeSupported(const String& mime) const
2522 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2523 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2525 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
2530 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
2532 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
2537 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
2539 __pUserUiListener = pUiEventListener;
2544 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
2546 __pUserKeypadEventListener = pKeypadEventListener;
2551 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
2553 if (__pWebDownloadHandler.get() == null)
2555 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
2556 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2559 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
2560 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
2565 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
2567 __pTextSearchListener = pTextSearchListener;
2572 _WebImpl::SetScrollEnabled(bool enable)
2574 _WebSettingImpl::GetInstance(__pWebSetting.get())->SetScrollEnabled(enable);
2581 _WebImpl::IsScrollEnabled(void) const
2583 return _WebSettingImpl::GetInstance(__pWebSetting.get())->IsScrollEnabled();
2588 _WebImpl::InitJsBridgeList(void)
2590 result r = E_SUCCESS;
2592 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
2593 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
2595 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
2596 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
2598 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
2599 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
2601 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
2602 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2604 __pJsBridgeList = std::move(pJsBridgeList);
2611 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
2613 result r = E_SUCCESS;
2615 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
2616 String key(pJsBridge->GetName());
2618 r = __pJsBridgeList->Add(key, pJsBridge);
2619 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2626 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
2628 result r = E_SUCCESS;
2630 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
2631 String key(pJsBridge->GetName());
2633 r = __pJsBridgeList->Remove(key);
2634 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2641 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
2643 result r = E_SUCCESS;
2645 IJsonValue* pJsonValue = null;
2646 IJavaScriptBridge* pJsBridge = null;
2648 String key(L"name");
2650 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
2651 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));
2653 r = pJsonObject->GetValue(&key, pJsonValue);
2654 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
2656 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
2657 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
2659 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
2660 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2667 _WebImpl::GetLoadingListener(void) const
2669 return __pUserLoadingListener;
2673 IWebUiEventListener*
2674 _WebImpl::GetUiEventListener(void) const
2676 return __pUserUiListener;
2680 IWebKeypadEventListener*
2681 _WebImpl::GetWebKeypadEventListener(void) const
2683 return __pUserKeypadEventListener;
2687 ITextSearchListener*
2688 _WebImpl::GetTextSearchListener(void) const
2690 return __pTextSearchListener;
2695 _WebImpl::SetEventListenerCallback(void) const
2697 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
2698 SysAssertf(pWebNativeNode, "Failed to get Web evas object");
2700 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
2701 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
2703 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
2704 SysAssertf(pWinObject, "Failed to get Ui window evas object");
2706 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
2707 SysAssertf(pSmartData, "Failed to request");
2709 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
2710 SysAssertf(pSmart, "Failed to request");
2712 pSmart->popup_menu_show = OnSelectBoxRequested;
2713 pSmart->popup_menu_hide = OnSelectBoxClosed;
2714 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
2716 pSmart->input_picker_show = OnDatePickerProviderRequested;
2717 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
2718 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
2720 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
2722 // add loading event callbacks for ILoadingListener
2723 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
2724 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
2726 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
2727 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
2728 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
2729 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
2730 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
2731 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
2732 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
2733 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
2734 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
2736 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
2738 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
2740 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
2741 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
2742 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
2744 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
2745 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
2747 evas_object_smart_callback_add(pWebNativeNode, "request,geolocation,permission", OnGeolocationPermissionRequested, this);
2749 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
2750 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
2751 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
2753 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
2755 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
2756 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
2758 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
2760 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
2761 SysAssertf(pContext, "Failed to get webkit instance.");
2762 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
2763 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
2765 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
2770 _WebImpl::RemoveEventListenerCallback(void) const
2772 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
2773 SysTryReturnVoidResult(NID_WEB_CTRL, pWebNativeNode, E_SYSTEM, "[%s] Failed to get Web evas object.", GetErrorMessage(E_SYSTEM));
2775 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
2776 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
2778 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
2779 SysAssertf(pWinObject, "Failed to get Ui window evas object");
2781 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
2782 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
2784 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
2785 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
2786 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
2787 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
2788 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
2789 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
2790 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
2791 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
2793 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
2795 evas_object_smart_callback_del(pWinObject, "focus,in", OnWindowObjectFocusGained);
2797 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
2798 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
2799 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
2801 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
2802 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
2804 evas_object_smart_callback_del(pWebNativeNode, "request,geolocation,permission", OnGeolocationPermissionRequested);
2806 ewk_view_javascript_alert_callback_set(null, null, null);
2807 ewk_view_javascript_prompt_callback_set(null, null, null);
2808 ewk_view_javascript_confirm_callback_set(null, null, null);
2810 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
2812 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
2813 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
2815 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
2817 ewk_view_open_panel_callback_set(null, null, null);
2819 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
2824 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
2826 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
2828 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
2829 SysAssertf(pSmartData, "Failed to request");
2831 Point absPoint(__pWebCore->GetAbsoluteCoordinate(startPoint));
2833 pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
2834 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
2836 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
2838 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
2840 if (__pUserUiListener)
2842 FireWebPageBlockSelectedEvent();
2850 _WebImpl::ReleaseBlock(void)
2852 ewk_view_command_execute(__pWebCore->GetWebNativeNode(), "Unselect", 0);
2859 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
2861 Eina_Rectangle leftHandle;
2862 Eina_Rectangle rightHandle;
2864 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
2866 startPoint.x = leftHandle.x;
2867 startPoint.y = leftHandle.y;
2868 endPoint.x = rightHandle.x + rightHandle.w;
2869 endPoint.y = rightHandle.y + rightHandle.h;
2871 if ((endPoint.x != 0) && (endPoint.y != 0))
2873 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
2874 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
2882 _WebImpl::FireWebPageBlockSelectedEvent(void) const
2884 result r = E_SUCCESS;
2886 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
2887 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
2888 SysTryReturnVoidResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2890 r = GetBlockRange(*startPoint.get(), *endPoint.get());
2891 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2893 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
2894 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2896 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
2897 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2898 startPoint.release();
2900 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
2901 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2904 r = __pWebEvent->FireAsync(*pEventArg.get());
2905 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2906 pEventArg.release();
2910 _WebImpl::SetLoadingErrorOccurred(bool arg)
2912 __isLoadingErrorOccurred = arg;
2917 _WebImpl::IsLoadingErrorOccurred(void) const
2919 return __isLoadingErrorOccurred;
2924 _WebImpl::SetRedirectRequested(bool arg)
2926 __isRedirectRequested = arg;
2931 _WebImpl::IsRedirectRequested(void) const
2933 return __isRedirectRequested;
2938 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
2945 _WebImpl::GetPolicyDecision(void) const
2952 _ConvertToOspErrorCode(int error)
2954 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
2958 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
2960 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
2962 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
2964 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
2966 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
2968 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
2970 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
2972 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
2974 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
2976 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
2978 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
2980 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
2982 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
2984 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
2986 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
2987 errorCode = WEB_NO_CONNECTION;
2990 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
2992 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
2993 errorCode = WEB_BAD_URL;
2996 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
2997 errorCode = WEB_FILE_ACCESS_FAILED;
3000 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
3001 errorCode = WEB_REQUEST_TIMEOUT;
3004 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
3005 errorCode = WEB_MIME_NOT_SUPPORTED;
3008 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
3009 errorCode = WEB_OUT_OF_MEMORY;
3012 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
3013 errorCode = WEB_REQUEST_MAX_EXCEEDED;
3016 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
3018 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
3020 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
3022 case EWK_ERROR_NETWORK_STATUS_OK:
3024 case EWK_ERROR_NETWORK_STATUS_CREATED:
3026 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
3028 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
3030 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
3032 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
3034 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
3036 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
3038 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
3040 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
3042 case EWK_ERROR_NETWORK_STATUS_FOUND:
3044 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
3046 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
3048 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
3050 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
3052 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
3053 errorCode = WEB_HTTP_RESPONSE;
3057 errorCode = WEB_INVALID_CERTIFICATE;
3061 errorCode = WEB_ERROR_UNKNOWN;
3070 _WebImpl::LaunchAppControl(const IEventArg& arg)
3072 result r = E_SUCCESS;
3074 IEventArg* pArg = const_cast< IEventArg* >(&arg);
3075 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
3076 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
3078 String operationId(L"");
3079 String uriPattern(pWebEventArg->GetEventMessage());
3080 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
3082 switch (pWebEventArg->GetEventType())
3084 case WEB_EVENT_REQUEST_RTSP:
3088 int uriLength = uriPattern.GetLength();
3091 operationId = L"http://tizen.org/appcontrol/operation/view";
3093 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
3094 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3096 r = uriPattern.SubString(index + 1, ext);
3097 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3099 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
3100 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3102 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
3103 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3107 case WEB_EVENT_REQUEST_TEL:
3109 operationId = L"http://tizen.org/appcontrol/operation/dial";
3112 case WEB_EVENT_REQUEST_EMAIL:
3114 case WEB_EVENT_REQUEST_SMS:
3116 case WEB_EVENT_REQUEST_MMS:
3118 operationId = L"http://tizen.org/appcontrol/operation/compose";
3121 case WEB_EVENT_REQUEST_UNKNOWN:
3130 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
3131 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3138 _WebImpl::SetFullScreenKeypad(void)
3140 result r = E_SUCCESS;
3142 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3143 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3145 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3146 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3148 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3149 pKeypad->SetText(text);
3151 r = pKeypad->SetShowState(true);
3152 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3154 r = pKeypad->Show();
3155 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3157 pKeypad->AddTextEventListener(*this);
3159 __pKeypad = std::move(pKeypad);
3166 _WebImpl::RemoveFullScreenKeypad(void)
3168 __pKeypad->RemoveTextEventListener(*this);
3175 _WebImpl::IsFooterVisible(void) const
3177 return __isFooterVisible;
3182 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3184 __isFooterVisible = isFooterVisible;
3189 _WebImpl::IsKeypadVisible(void) const
3191 return __isKeypadVisible;
3196 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3198 __isKeypadVisible = isKeypadVisible;
3203 _WebImpl::IsKeypadOpened(void) const
3205 return __isKeypadOpened;
3209 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
3211 __isKeypadOpened = isKeypadOpened;
3216 _WebImpl::GetKeypadHeight(void) const
3218 return __keypadHeight;
3223 _WebImpl::SetKeypadHeight(int keypadHeight)
3225 __keypadHeight = keypadHeight;
3230 _WebImpl::GetPreviousOrientation(void) const
3232 return __orientation;
3237 _WebImpl::SetPreviousOrientation(_ControlOrientation orientation)
3239 __orientation = orientation;
3244 _WebImpl::OnTextValueChangeCanceled(const Control& source)
3246 RemoveFullScreenKeypad();
3251 _WebImpl::OnTextValueChanged(const Control& source)
3253 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
3255 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
3257 RemoveFullScreenKeypad();
3262 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
3264 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
3265 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
3267 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
3268 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3270 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
3271 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
3273 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
3280 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
3282 result r = E_SUCCESS;
3284 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
3285 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3287 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3289 ILoadingListener* pLoadingListner = GetLoadingListener();
3290 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
3292 switch (pEventArg->GetEventType())
3294 case WEB_EVENT_LOADINGLISTENER_STARTED:
3296 pLoadingListner->OnLoadingStarted();
3300 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
3302 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
3303 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3305 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
3309 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
3311 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
3312 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3314 pLoadingListner->OnPageTitleReceived(*pPageTitle);
3318 case WEB_EVENT_LOADINGLISTENER_CANCELED:
3320 pLoadingListner->OnLoadingCanceled();
3324 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
3326 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
3327 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3329 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
3330 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3332 LoadingErrorType errorType = _ConvertToOspErrorCode(pErrorType->ToInt());
3334 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
3338 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
3340 pLoadingListner->OnLoadingCompleted();
3344 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
3346 pLoadingListner->OnHttpAuthenticationCanceled();
3361 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
3363 result r = E_SUCCESS;
3365 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
3366 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3368 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3370 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
3371 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
3373 switch (pEventArg->GetEventType())
3375 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
3377 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
3378 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3380 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
3384 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
3386 pWebDownloadListener->OnWebDataDownloadCompleted();
3390 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
3392 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
3393 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3395 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
3397 pWebDownloadListener->OnWebDownloadFailed(errorType);
3412 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
3414 result r = E_SUCCESS;
3416 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
3417 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3419 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3421 IWebUiEventListener* pWebUiEventListner = GetUiEventListener();
3422 SysTryReturnResult(NID_WEB_CTRL, pWebUiEventListner, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
3424 switch (pEventArg->GetEventType())
3426 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
3428 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3430 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
3431 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3433 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
3434 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3436 pWebUiEventListner->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
3440 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
3442 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3444 pWebUiEventListner->OnWebPageShowRequested(*pWeb);
3448 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
3450 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3452 pWebUiEventListner->OnWebWindowCloseRequested(*pWeb);
3467 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
3469 result r = E_SUCCESS;
3471 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
3472 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3474 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3476 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
3477 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
3479 switch (pEventArg->GetEventType())
3481 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
3483 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
3484 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3486 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
3487 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3489 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
3504 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
3506 result r = E_SUCCESS;
3508 String host(ewk_auth_challenge_url_get(pChallenge));
3509 String realm(ewk_auth_challenge_realm_get(pChallenge));
3511 __pAuthChallenge.reset();
3513 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
3514 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
3516 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
3517 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3519 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
3520 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
3522 __pAuthChallenge = std::move(pAuthChallenge);
3524 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
3526 __pAuthChallenge.release();
3530 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
3531 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3539 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
3541 result r = E_SUCCESS;
3543 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
3544 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
3546 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
3547 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3549 __pAuthPopup = std::move(pAuthPopup);
3551 r = __pAuthPopup->ShowPopup();
3552 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3555 __pAuthPopup.reset();
3562 _WebImpl::ShowGeolocationPopup(Ewk_Geolocation_Permission_Data* pPermissionData)
3564 result r = E_SUCCESS;
3566 std::unique_ptr<_GeolocationConfirmPopup> pGeolocationPopup(new (std::nothrow) _GeolocationConfirmPopup());
3567 SysTryReturnResult(NID_WEB_CTRL, pGeolocationPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3569 r = pGeolocationPopup->Construct(pPermissionData);
3570 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3572 __pGeolocationPopup = std::move(pGeolocationPopup);
3574 r = __pGeolocationPopup->ShowPopup();
3575 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3577 __pGeolocationPopup.release();
3582 __pGeolocationPopup.reset();
3589 _WebImpl::GetParentFormCore(_Control* pControlCore)
3592 _Form* pFormCore = null;
3594 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
3596 if (pParentControlCore == null)
3598 _Window* pWindowCore = dynamic_cast< _Window* >(pControlCore);
3599 SysAssertf(pWindowCore, "Failed to get parent control and window core.");
3600 pFormCore = dynamic_cast< _Form* >(pWindowCore->GetOwner());
3601 if (pFormCore == null)
3603 pParentControlCore = dynamic_cast< _Control* >(pWindowCore->GetOwner());
3604 SysTryReturn(NID_WEB_CTRL, pParentControlCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3609 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
3612 if (pFormCore != null)
3617 return GetParentFormCore(pParentControlCore);
3622 _WebImpl::OnFocusGained(const _ControlImpl& source)
3629 _WebImpl::OnFocusLost(const _ControlImpl& source)
3631 if(IsKeypadVisible() == true)
3633 SetKeypadOpened(true);
3636 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
3643 _WebImpl::HasValidNativeNode(void) const
3645 if (__pWebCore && __pWebCore->GetWebNativeNode())
3655 _WebImpl::OnAttachedToMainTree(void)
3657 result r = E_SUCCESS;
3659 r = __pWebCore->InitializeWebNativeNode();
3660 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3662 r = InitializeSetting();
3663 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3665 r = _ContainerImpl::OnAttachedToMainTree();
3666 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3673 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
3675 if (IsKeypadVisible() == true)
3677 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
3678 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
3680 _Form* pFormCore = GetParentFormCore(dynamic_cast< _Control* >(&this->GetCore()));
3681 SysAssertf(pFormCore != null, "Failed to get FormCore");
3683 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
3685 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(PORTRAIT_KEYPAD_HEIGHT));
3687 else if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
3689 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(LANDSCAPE_KEYPAD_HEIGHT));
3693 if (__pColorPicker.get())
3695 __pColorPicker->ChangeLayout(orientation);
3702 _WebImpl::GetDownloadHandler(void) const
3704 return __pWebDownloadHandler.get();
3709 _WebImpl::GetFaviconN(void) const
3711 result r = E_SUCCESS;
3713 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3715 Evas* pEvas = evas_object_evas_get(pView);
3716 Ewk_Context* pContext = ewk_view_context_get(pView);
3717 SysAssertf(pEvas && pContext, "Failed to request");
3719 const char* pUrl = ewk_view_url_get(pView);
3721 Tizen::Graphics::BufferInfo bufferInfo;
3722 Tizen::Base::ByteBuffer byteBuffer;
3724 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3725 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3727 Evas_Object* pfavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3728 SysTryReturn(NID_WEB_CTRL, pfavicon, null, E_OBJ_NOT_FOUND, "[%s] Propagating.", GetErrorMessage(E_OBJ_NOT_FOUND));
3730 r = _Utility::GetPixelBufferFromEvasObject(pfavicon, bufferInfo);
3731 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3733 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3735 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3736 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3738 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3739 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3741 return pBitmapImage.release();
3747 _WebImpl::GetInstance(Web* pWeb)
3749 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
3754 _WebImpl::GetInstance(const Web* pWeb)
3756 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
3761 _WebImpl::HideColorPicker()
3763 __pColorPicker.reset();
3770 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
3772 result r = E_SUCCESS;
3774 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
3775 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3777 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
3779 r = pColorHadler->Construct(colorVal);
3780 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3782 __pColorPicker = std::move(pColorHadler);
3784 r = __pColorPicker->ShowPopup();
3785 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3787 color = __pColorPicker->GetColor();
3792 __pColorPicker.reset();
3799 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
3801 result r = E_SUCCESS;
3803 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
3804 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3806 r = pInputPicker->Construct(String(inputValue), inputType);
3807 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3809 __pDatePicker = std::move(pInputPicker);
3811 r = __pDatePicker->ShowPopup();
3812 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3814 dateStr = __pDatePicker->GetDate();
3817 __pDatePicker.reset();
3823 }}} // Tizen::Web::Controls