2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_WebImpl.cpp
20 * @brief The file contains the definition of _WebImpl class.
22 * The file contains the definition of _WebImpl class.
24 #include <Ecore_IMF_Evas.h>
25 #include <Ecore_Evas.h>
26 #include <elm_config.h>
29 #include <ewk_popup_menu_item.h>
30 #include <libsoup/soup-status.h>
32 #include <FAppAppControl.h>
33 #include <FAppIAppControlListener.h>
34 #include <FBaseColAllElementsDeleter.h>
35 #include <FBaseColHashMapT.h>
36 #include <FBaseRtMutex.h>
37 #include <FBaseRtMutexGuard.h>
38 #include <FBaseSysLog.h>
39 #include <FBaseUtilUri.h>
40 #include <FCntDownloadRequest.h>
41 #include <FGrpColor.h>
42 #include <FGrpPoint.h>
43 #include <FGrpRectangle.h>
44 #include <FIoDbEnumerator.h>
45 #include <FIoDbStatement.h>
47 #include <FMediaImage.h>
48 #include <FMediaImageTypes.h>
49 #include <FNetHttpHttpHeader.h>
50 #include <FSysVibrator.h>
51 #include <FUiControl.h>
52 #include <FUiCtrlKeypad.h>
53 #include <FWebCtrlHitElementResult.h>
54 #include <FWebCtrlITextSearchListener.h>
55 #include <FWebCtrlIWebDownloadListener.h>
56 #include <FWebCtrlIWebUiEventListener.h>
57 #include <FWebCtrlIWebUiEventListenerF.h>
58 #include <FWebCtrlIWebKeypadEventListener.h>
59 #include <FWebCtrlIJavaScriptBridge.h>
60 #include <FWebCtrlPageNavigationList.h>
61 #include <FWebCtrlAuthenticationChallenge.h>
62 #include <FWebCtrlWeb.h>
63 #include <FWebCtrlWebSetting.h>
64 #include <FWebHistoryItem.h>
65 #include <FWebJsonJsonObject.h>
66 #include <FWebJsonJsonParser.h>
67 #include <FWebJsonJsonString.h>
68 #include <FApp_AppControlImpl.h>
69 #include <FApp_AppControlManager.h>
70 #include <FApp_AppInfo.h>
71 #include <FApp_AppManagerImpl.h>
72 #include <FBase_StringConverter.h>
73 #include <FCnt_DownloadManagerImpl.h>
74 #include <FCnt_ContentManagerImpl.h>
75 #include <FGrp_CoordinateSystem.h>
76 #include <FGrp_Screen.h>
77 #include <FIo_DatabaseImpl.h>
78 #include <FIo_NormalFile.h>
79 #include <FSys_SystemResource.h>
80 #include <FSys_VibratorImpl.h>
81 #include <FUi_Control.h>
82 #include <FUi_CoordinateSystemUtils.h>
83 #include <FUi_EcoreEvasMgr.h>
84 #include <FUi_EcoreEvas.h>
85 #include <FUi_ResourceSizeInfo.h>
86 #include <FUi_Window.h>
87 #include <FUiAnim_EflNode.h>
88 #include <FUiAnim_VisualElement.h>
89 #include <FUiCtrl_FooterImpl.h>
90 #include <FUiCtrl_FormImpl.h>
91 #include "FWeb_HistoryItemImpl.h"
92 #include "FWebCtrl_AppControlListener.h"
93 #include "FWebCtrl_AuthConfirmPopup.h"
94 #include "FWebCtrl_AuthenticationChallengeImpl.h"
95 #include "FWebCtrl_EflWebkit.h"
96 #include "FWebCtrl_FormDataWindow.h"
97 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
98 #include "FWebCtrl_HitElementResultImpl.h"
99 #include "FWebCtrl_InputPickerPopup.h"
100 #include "FWebCtrl_WebNotification.h"
101 #include "FWebCtrl_PageNavigationListImpl.h"
102 #include "FWebCtrl_PromptPopup.h"
103 #include "FWebCtrl_SelectBox.h"
104 #include "FWebCtrl_Utility.h"
105 #include "FWebCtrl_Web.h"
106 #include "FWebCtrl_WebDataHandler.h"
107 #include "FWebCtrl_WebEvent.h"
108 #include "FWebCtrl_WebEventArg.h"
109 #include "FWebCtrl_WebImpl.h"
110 #include "FWebCtrl_WebManager.h"
111 #include "FWebCtrl_WebPresenter.h"
112 #include "FWebCtrl_WebSettingImpl.h"
115 using namespace Tizen::App;
116 using namespace Tizen::Base;
117 using namespace Tizen::Base::Collection;
118 using namespace Tizen::Base::Runtime;
119 using namespace Tizen::Base::Utility;
120 using namespace Tizen::Content;
121 using namespace Tizen::Graphics;
122 using namespace Tizen::Io;
123 using namespace Tizen::Media;
124 using namespace Tizen::Net::Http;
125 using namespace Tizen::System;
126 using namespace Tizen::Ui;
127 using namespace Tizen::Ui::Animations;
128 using namespace Tizen::Ui::Controls;
129 using namespace Tizen::Web::Json;
132 namespace Tizen { namespace Web { namespace Controls
136 static const char WEB_CTRL[] = "webcontrol";
137 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
140 static const float MIN_ZOOM_LEVEL = 0.3;
141 static const float MAX_ZOOM_LEVEL = 2;
144 static const int REDIRECTION_HEADER_GROUP = 300;
147 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
150 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
151 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
152 static const int DEFAULT_LIST_ITEM_COUNT = 4;
155 class _JsBridgeHashCodeProvider
156 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
159 _JsBridgeHashCodeProvider(){}
160 virtual ~_JsBridgeHashCodeProvider(void) {}
163 int GetHashCode(const Tizen::Base::String& obj) const
165 return obj.GetHashCode();
171 //Comparer implementation
172 class _JsBridgeComparer
173 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
176 _JsBridgeComparer(){}
177 virtual ~_JsBridgeComparer(void) {}
180 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
197 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
198 : _ContainerImpl(pWeb, pCore)
199 , __isFooterVisible(false)
200 , __isKeypadVisible(false)
201 , __isKeypadOpened(false)
202 , __isLoadingErrorOccurred(false)
203 , __isRedirectRequested(false)
204 , __isCertificateRequested(false)
205 , __isCertificateConfirmed(false)
206 , __isFormDataVisible(false)
207 , __previousKeypadBounds(0, 0, 0, 0)
209 , __pUserLoadingListener(null)
210 , __pUserUiListener(null)
211 , __pUserUiListenerF(null)
212 , __pUserKeypadEventListener(null)
213 , __pTextSearchListener(null)
215 , __pJsBridgeList(null)
216 , __pJsProvider(null)
217 , __pJsComparer(null)
218 , __pWebDownloadHandler(null)
220 , __pAuthChallenge(null)
222 , __pUserMediaConfirmPopup(null)
223 , __pContentHandlerConfirmPopup(null)
224 , __pProtocolHandlerConfirmPopup(null)
225 , __pGeolocationConfirmPopup(null)
226 , __pNotificationConfirmPopup(null)
227 , __pScriptAlertConfirmPopup(null)
228 , __pScriptConfirmPopup(null)
229 , __pAppCacheConfirmPopup(null)
230 , __pDbQuotaConfirmPopup(null)
231 , __pLocalFsQuotaConfirmPopup(null)
232 , __pIndexedDbQuotaConfirmPopup(null)
233 , __pPromptPopup(null)
234 , __pCertConfirmPopup(null)
236 , __pDatePicker(null)
237 , __pColorPicker(null)
238 , __pFormDataWindow(null)
240 , __policy(WEB_DECISION_CONTINUE)
241 , __defaultUserAgent(L"")
242 , __pFormDataList(null)
243 , __popupClosed(false)
245 __textSearch.__searchAll = false;
246 __textSearch.__searchForward = true;
247 __textSearch.__caseSensitive = false;
248 __textSearch.__pending = 0;
249 __textSearch.__currentIndex = 1;
250 __textSearch.__totalCount = -1;
251 __textSearch.__text = L"";
255 _WebImpl::~_WebImpl()
257 ClearCertificateDb();
262 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
264 result r = E_SUCCESS;
266 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
267 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
269 _Web* pCore = _Web::CreateWebN();
270 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
272 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
274 r = CheckConstruction(pCore, pImpl);
275 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
277 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
278 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
280 r = pImpl->Construct();
281 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
293 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
295 result r = E_SUCCESS;
297 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
298 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
300 _Web* pCore = _Web::CreateWebN();
301 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
303 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
305 r = CheckConstruction(pCore, pImpl);
306 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
308 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
309 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
311 r = pImpl->Construct();
312 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
324 _WebImpl::Construct(void)
326 result r = E_SUCCESS;
328 r = __mutex.Create();
329 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
331 r = __textSearch.__searchQueue.Construct();
332 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
334 r = __webNotificationList.Construct();
335 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
337 r = InitJsBridgeList();
338 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
341 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
343 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
344 SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
346 pManagerImpl->SetDownloadListener(this);
348 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
349 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
356 _WebImpl::InitializeSetting(void)
358 result r = E_SUCCESS;
360 WebSetting* pWebSetting = __pWebCore->GetSetting();
361 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
363 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
364 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
366 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
368 r = SetSetting(*pWebSetting);
369 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
371 SetEventListenerCallback();
378 _WebImpl::IsLayoutable(void) const
385 _WebImpl::InitWebEvent(void)
387 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
388 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
390 return __pWebEvent->Construct(*this);
395 _WebImpl::GetWebEvent(void) const
397 return __pWebEvent.get();
402 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
404 Eina_Hash* pHttpHeader = null;
406 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
407 if (pFieldNameList.get())
409 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
410 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
412 int count = pFieldNameList->GetCount();
414 for (int i = 0; i < count; i++)
416 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
417 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
419 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
420 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
422 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
423 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
425 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
427 Eina_Bool ret = false;
429 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
430 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
432 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
433 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
435 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
436 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
443 eina_hash_free(pHttpHeader);
450 _WebImpl::LoadUrl(const String& url) const
452 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
453 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
455 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
462 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
464 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
465 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
467 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
469 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
471 eina_hash_free(pHttpHeader);
478 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
480 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
481 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
483 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
485 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
487 eina_hash_free(pHttpHeader);
494 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
496 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
498 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
499 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
500 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
501 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
503 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
510 _WebImpl::Pause(void)
512 ewk_view_suspend(__pWebCore->GetWebNativeNode());
517 _WebImpl::Resume(void)
519 ewk_view_resume(__pWebCore->GetWebNativeNode());
524 _WebImpl::CanGoBack(void) const
526 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
531 _WebImpl::CanGoForward(void) const
533 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
538 _WebImpl::GoBack(void) const
540 ewk_view_back(__pWebCore->GetWebNativeNode());
545 _WebImpl::GoForward(void) const
547 ewk_view_forward(__pWebCore->GetWebNativeNode());
552 _WebImpl::GetUrl(void) const
554 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
559 _WebImpl::GetTitle(void) const
561 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
566 _WebImpl::StopLoading(void) const
568 ewk_view_stop(__pWebCore->GetWebNativeNode());
573 _WebImpl::Reload(void) const
575 ewk_view_reload(__pWebCore->GetWebNativeNode());
580 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
582 Evas_Object* pView = __pWebCore->GetWebNativeNode();
588 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
589 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
591 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
592 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
594 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
596 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
597 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
599 pPresenter->WaitAsyncProcess(*pResult.get());
601 return pResult.release();
606 _WebImpl::SetZoomLevel(float level)
608 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);
610 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
617 _WebImpl::GetZoomLevel(void) const
619 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
623 const PageNavigationList*
624 _WebImpl::GetBackForwardListN(void) const
626 Evas_Object* pView = __pWebCore->GetWebNativeNode();
632 result r = E_SUCCESS;
634 _PageNavigationListImpl* pNavigationListImpl = null;
635 _HistoryItemImpl* pHistoryItemImpl = null;
637 std::unique_ptr<PageNavigationList> pNavigationList;
638 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
641 int forwardCount = 0;
646 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
647 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
649 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
650 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
652 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
653 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
655 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
656 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
658 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
659 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
661 r = pHistoryList->Construct();
662 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
664 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
665 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
666 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
668 for (int i = -backCount; i < forwardCount + 1; i++)
670 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
671 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
673 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
674 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
676 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
677 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
679 url = ewk_history_item_uri_get(pEwkItem);
680 title = ewk_history_item_title_get(pEwkItem);
681 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
683 pHistoryItemImpl->SetHistoryItem(url, title);
685 r = pHistoryList->Add(*pHistoryItem.get());
686 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
687 pHistoryItem.release();
690 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
692 ewk_history_free(pEwkHistoryList);
694 return pNavigationList.release();
697 ewk_history_free(pEwkHistoryList);
704 _WebImpl::SearchText(const String& text, bool searchForward)
706 Evas_Object* pView = __pWebCore->GetWebNativeNode();
712 result r = E_SUCCESS;
714 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
718 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
721 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
722 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
724 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
725 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
728 pPresenter->WaitAsyncProcess(result);
730 return static_cast < bool >(result);
735 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
737 Evas_Object* pView = __pWebCore->GetWebNativeNode();
743 result r = E_SUCCESS;
745 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
749 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
752 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
753 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
760 _WebImpl::SearchNextAsync(bool searchForward)
762 Evas_Object* pView = __pWebCore->GetWebNativeNode();
768 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
769 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
770 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
772 result r = E_SUCCESS;
774 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
776 if (!__textSearch.__caseSensitive)
778 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
783 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
786 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
787 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
794 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
796 MutexGuard lock(__mutex);
798 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
799 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
804 if (__textSearch.__searchAll)
806 DisableAsyncSearch();
808 __textSearch.__searchQueue.Enqueue(this);
809 __textSearch.__searchQueue.Enqueue(pWebPresenter);
811 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
812 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
816 __textSearch.__searchQueue.Enqueue(pWebPresenter);
818 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
822 case SEARCH_ALL_ASYNC:
823 __textSearch.__searchAll = true;
824 __textSearch.__text = text;
825 __textSearch.__searchForward = true;
826 __textSearch.__caseSensitive = caseSensitive;
827 __textSearch.__totalCount = -1;
828 __textSearch.__currentIndex = 1;
830 __textSearch.__searchQueue.Enqueue(this);
831 __textSearch.__searchQueue.Enqueue(this);
833 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
834 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
837 case SEARCH_NEXT_ASYNC:
838 __textSearch.__searchForward = searchForward;
840 CalculateAsyncSearchOrdinal();
842 __textSearch.__searchQueue.Enqueue(this);
844 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
856 _WebImpl::SetAsyncSearchResult(int totalCount)
858 __textSearch.__totalCount = totalCount;
863 _WebImpl::GetSearchPresenter(void)
865 MutexGuard lock(__mutex);
867 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
872 _WebImpl::GetPendingAsyncSearchCount(void) const
874 return __textSearch.__searchQueue.GetCount();
879 _WebImpl::CalculateAsyncSearchOrdinal(void)
881 if (__textSearch.__searchForward)
883 __textSearch.__currentIndex++;
887 __textSearch.__currentIndex--;
893 _WebImpl::GetAsyncSearchOrdinal(void) const
895 return __textSearch.__currentIndex;
900 _WebImpl::DisableAsyncSearch(void)
902 __textSearch.__searchAll = false;
907 _WebImpl::SetSetting(const WebSetting& setting)
909 if (__pWebCore->GetWebNativeNode())
911 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
912 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
913 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
915 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
916 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
918 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
920 switch (setting.GetCacheControl())
922 case WEB_CACHE_VALIDATED:
923 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
926 case WEB_CACHE_IGNORE:
927 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
934 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
936 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
940 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
943 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
945 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
947 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
949 if (__defaultUserAgent != setting.GetUserAgent())
951 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
952 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
954 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
957 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
959 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
961 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
963 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
966 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
968 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
969 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
970 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
971 pWebSettingImpl->SetFontSize(setting.GetFontSize());
972 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
973 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
974 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
975 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
976 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
977 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
978 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
979 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
980 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
987 _WebImpl::GetSetting(void) const
989 return *__pWebCore->GetSetting();
993 const HitElementResult*
994 _WebImpl::GetElementByPointN(const Point& point) const
996 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
1000 const HitElementResult*
1001 _WebImpl::GetElementByPointN(const FloatPoint& point) const
1003 Evas_Object* pView = __pWebCore->GetWebNativeNode();
1009 SysTryReturn(NID_WEB_CTRL, Contains(point), null, E_INVALID_ARG, "[%s] The point must be contained in the bounds of a web control.", GetErrorMessage(E_INVALID_ARG));
1011 result r = E_SUCCESS;
1013 _HitElementResultImpl* pHitElementResultImpl = null;
1015 std::unique_ptr<HitElementResult> pHitElementResult;
1016 std::unique_ptr<Bitmap> pImage;
1017 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
1019 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
1021 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
1022 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
1024 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
1025 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
1026 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
1027 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
1028 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
1030 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
1032 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
1033 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1035 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
1036 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1038 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
1044 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
1045 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
1046 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
1047 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
1049 r = buf.Construct(imageLength);
1050 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1052 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
1053 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1057 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
1058 // webkit support types such as ico and vp8 additionally
1059 if (strcmp(pExtension, "gif") == 0)
1061 format = IMG_FORMAT_GIF;
1063 else if (strcmp(pExtension, "jpg") == 0)
1065 format = IMG_FORMAT_JPG;
1067 else if (strcmp(pExtension, "png") == 0)
1069 format = IMG_FORMAT_PNG;
1071 else if (strcmp(pExtension, "bmp") == 0)
1073 format = IMG_FORMAT_BMP;
1077 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
1081 r = image.Construct();
1082 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1084 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
1085 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1090 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
1091 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1093 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
1094 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1096 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
1097 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1100 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
1102 ewk_hit_test_free(pEwkHitTest);
1104 return pHitElementResult.release();
1107 ewk_hit_test_free(pEwkHitTest);
1114 _WebImpl::IsLoading(void) const
1116 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
1118 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
1130 _WebImpl::GetTextFromBlock(void) const
1132 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
1137 _WebImpl::IsPrivateBrowsingEnabled(void) const
1139 if (__pWebCore->GetWebNativeNode() == null)
1141 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
1144 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
1145 SysAssertf(pSettings, "Failed to get webkit instance.");
1147 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
1152 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
1154 if (__pWebCore->GetWebNativeNode() == null)
1156 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
1160 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
1161 SysAssertf(pSettings, "Failed to get webkit instance.");
1163 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
1168 _WebImpl::ClearHistory(void)
1170 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
1175 _WebImpl::ClearCache(void)
1177 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
1179 ewk_context_cache_clear(pContext);
1184 _WebImpl::ClearCookie(void)
1186 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
1187 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
1189 ewk_cookie_manager_cookies_clear(pCookieManager);
1194 _WebImpl::ClearFormData(void)
1196 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
1198 ewk_context_form_candidate_data_clear(pContext);
1203 _WebImpl::ClearLoginFormData(void)
1205 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
1207 ewk_context_form_password_data_clear(pContext);
1212 _WebImpl::IsCookieEnabled(void) const
1214 if (__pWebCore->GetWebNativeNode() == null)
1216 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
1219 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
1220 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
1221 SysAssertf(pCookieManager, "Failed to get webkit instance.");
1223 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
1224 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1226 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
1228 bool result = false;
1229 pPresenter->WaitAsyncProcess(result);
1236 _WebImpl::SetCookieEnabled(bool enable)
1238 if (__pWebCore->GetWebNativeNode() == null)
1240 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
1245 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
1246 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
1247 SysAssertf(pCookieManager, "Failed to get webkit instance.");
1251 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
1255 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
1256 ewk_cookie_manager_cookies_clear(pCookieManager);
1262 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
1264 result r = E_SUCCESS;
1266 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
1267 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1270 String fileExtension = File::GetFileExtension(filePath);
1271 int pathLength = filePath.GetLength();
1274 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
1276 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
1277 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
1278 r = filePath.SubString(0, index + 1, dirPath);
1279 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
1281 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
1282 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
1286 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
1288 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
1292 Evas_Coord contentsWidth;
1293 Evas_Coord contentsHeight;
1295 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
1296 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
1304 _WebImpl::IsMimeSupported(const String& mime) const
1306 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
1307 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1309 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
1314 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
1316 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
1321 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
1323 __pUserUiListener = pUiEventListener;
1328 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
1330 __pUserUiListenerF = pUiEventListener;
1335 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
1337 __pUserKeypadEventListener = pKeypadEventListener;
1342 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
1344 if (__pWebDownloadHandler.get() == null)
1346 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
1347 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1350 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
1351 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
1356 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
1358 __pTextSearchListener = pTextSearchListener;
1363 _WebImpl::SetScrollEnabled(bool enable)
1365 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
1370 _WebImpl::IsScrollEnabled(void) const
1372 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
1377 _WebImpl::InitJsBridgeList(void)
1379 result r = E_SUCCESS;
1381 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
1382 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1384 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
1385 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1387 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
1388 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1390 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
1391 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1393 __pJsBridgeList = std::move(pJsBridgeList);
1400 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
1402 result r = E_SUCCESS;
1404 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
1405 String key(pJsBridge->GetName());
1407 r = __pJsBridgeList->Add(key, pJsBridge);
1408 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1415 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
1417 result r = E_SUCCESS;
1419 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
1420 String key(pJsBridge->GetName());
1422 r = __pJsBridgeList->Remove(key);
1423 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1430 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
1432 result r = E_SUCCESS;
1434 IJsonValue* pJsonValue = null;
1435 IJavaScriptBridge* pJsBridge = null;
1437 String key(L"name");
1439 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
1440 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));
1442 r = pJsonObject->GetValue(&key, pJsonValue);
1443 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
1445 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
1446 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
1448 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
1449 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1456 _WebImpl::GetLoadingListener(void) const
1458 return __pUserLoadingListener;
1462 IWebUiEventListener*
1463 _WebImpl::GetUiEventListener(void) const
1465 return __pUserUiListener;
1469 IWebUiEventListenerF*
1470 _WebImpl::GetUiEventListenerF(void) const
1472 return __pUserUiListenerF;
1476 IWebKeypadEventListener*
1477 _WebImpl::GetWebKeypadEventListener(void) const
1479 return __pUserKeypadEventListener;
1483 ITextSearchListener*
1484 _WebImpl::GetTextSearchListener(void) const
1486 return __pTextSearchListener;
1491 _WebImpl::SetEventListenerCallback(void) const
1493 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
1496 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1497 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
1499 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
1500 SysAssertf(pWinObject, "Failed to get Ui window evas object");
1502 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
1503 SysAssertf(pSmartData, "Failed to request");
1505 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
1506 SysAssertf(pSmart, "Failed to request");
1508 pSmart->popup_menu_show = OnSelectBoxRequested;
1509 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
1510 pSmart->popup_menu_hide = OnSelectBoxClosed;
1511 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
1513 pSmart->input_picker_show = OnDatePickerProviderRequested;
1514 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
1515 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
1517 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
1518 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
1519 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
1520 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
1522 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
1524 // add loading event callbacks for ILoadingListener
1525 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
1526 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
1528 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
1529 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
1530 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
1531 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
1532 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
1533 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
1534 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
1535 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
1537 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
1539 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
1541 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
1542 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
1543 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
1545 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
1546 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
1548 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
1550 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
1551 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
1552 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
1554 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
1556 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
1557 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
1558 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
1560 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
1561 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
1562 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
1564 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
1565 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
1566 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
1568 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
1569 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
1570 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
1571 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
1573 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
1574 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
1576 evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
1578 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
1579 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
1581 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
1582 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
1583 SysAssertf(pContext, "Failed to get webkit instance.");
1584 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
1585 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
1587 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
1588 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
1589 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
1590 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
1592 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
1598 _WebImpl::RemoveEventListenerCallback(void) const
1600 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
1603 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1604 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
1606 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
1607 SysAssertf(pWinObject, "Failed to get Ui window evas object");
1609 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
1610 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
1612 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
1613 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
1614 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
1615 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
1616 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
1617 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
1618 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
1619 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
1621 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
1623 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
1625 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
1626 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
1627 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
1629 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
1630 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
1632 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
1634 ewk_view_javascript_alert_callback_set(null, null, null);
1635 ewk_view_javascript_prompt_callback_set(null, null, null);
1636 ewk_view_javascript_confirm_callback_set(null, null, null);
1638 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
1640 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
1641 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
1642 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
1644 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
1645 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
1646 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
1647 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
1648 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
1649 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
1651 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
1652 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
1653 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
1655 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
1657 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
1658 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
1660 evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
1662 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
1663 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
1665 ewk_view_open_panel_callback_set(null, null, null);
1666 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
1667 SysAssertf(pContext, "Failed to get webkit instance.");
1668 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
1670 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
1671 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
1672 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
1673 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
1675 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
1681 _WebImpl::ClearCertificateDb(void)
1683 result r = E_SUCCESS;
1685 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
1686 String table(CERTIFICATE_TABLE_NAME);
1689 r = db.Construct(certificatePath, "r+", null);
1690 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1692 db.BeginTransaction();
1694 r = db.ExecuteSql(L"Delete From " + table, true);
1695 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1697 db.CommitTransaction();
1702 db.RollbackTransaction();
1707 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
1709 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
1714 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
1716 Evas_Object* pView = __pWebCore->GetWebNativeNode();
1717 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
1718 if (pSmartData && pSmartData->api)
1720 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
1722 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
1725 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
1727 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
1728 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
1730 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
1732 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
1734 ewk_view_command_execute(pView, "SelectWord", 0);
1738 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
1739 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
1742 ewk_view_command_execute(pView, "SelectWord", 0);
1748 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
1750 evas_object_smart_callback_call(pView, "text,selected", NULL);
1757 _WebImpl::ReleaseBlock(void)
1759 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
1764 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
1766 FloatPoint tempStartPoint;
1767 FloatPoint tempEndPoint;
1769 GetBlockRange(tempStartPoint, tempEndPoint);
1771 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
1772 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
1777 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
1779 Eina_Rectangle leftHandle;
1780 Eina_Rectangle rightHandle;
1782 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
1783 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
1785 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
1787 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
1788 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
1789 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
1790 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
1792 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
1794 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
1795 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
1801 _WebImpl::GetFaviconN(void) const
1803 result r = E_SUCCESS;
1805 Evas_Object* pView = __pWebCore->GetWebNativeNode();
1806 Ewk_Context* pContext = ewk_view_context_get(pView);
1807 const char* pUrl = ewk_view_url_get(pView);
1808 Evas* pEvas = evas_object_evas_get(pView);
1810 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
1816 Tizen::Graphics::BufferInfo bufferInfo;
1818 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
1819 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1821 const Dimension dimension(bufferInfo.width, bufferInfo.height);
1822 Tizen::Base::ByteBuffer byteBuffer;
1824 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
1825 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1827 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
1828 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1830 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
1831 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1833 return pImage.release();
1839 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
1841 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
1846 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
1848 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
1853 _WebImpl::GetScrollPosition(void) const
1857 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
1864 _WebImpl::GetPageSize(void) const
1866 Evas_Coord width = 0;
1867 Evas_Coord height = 0;
1869 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
1871 Dimension size(static_cast< int >(width), static_cast< int >(height));
1878 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
1880 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
1882 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
1883 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1885 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
1887 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
1894 _WebImpl::RemoveHttpHeaderField(const String& name)
1896 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
1898 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
1899 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1901 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
1908 _WebImpl::SetFullScreenKeypad(void)
1910 result r = E_SUCCESS;
1912 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
1913 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1915 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
1916 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1918 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
1919 pKeypad->SetText(text);
1921 r = pKeypad->SetShowState(true);
1922 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1924 r = pKeypad->Show();
1925 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1927 pKeypad->AddTextEventListener(*this);
1929 __pKeypad = std::move(pKeypad);
1936 _WebImpl::RemoveFullScreenKeypad(void)
1938 __pKeypad->RemoveTextEventListener(*this);
1945 _WebImpl::IsKeypadVisible(void) const
1947 return __isKeypadVisible;
1952 _WebImpl::GetPreviousKeypadBounds(void) const
1954 return __previousKeypadBounds;
1959 _WebImpl::OnTextValueChangeCanceled(const Control& source)
1961 RemoveFullScreenKeypad();
1966 _WebImpl::OnTextValueChanged(const Control& source)
1968 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
1970 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
1972 RemoveFullScreenKeypad();
1977 _WebImpl::AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
1979 result r = E_SUCCESS;
1981 String key(reinterpret_cast< const char* >(pKey));
1982 String value(reinterpret_cast< char* >(pValue));
1984 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
1986 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
1987 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1994 _WebImpl::AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
1996 result r = E_SUCCESS;
1998 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
1999 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
2000 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2002 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
2004 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
2005 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2007 pAttrValue.release();
2014 _WebImpl::FreeCharArray(void* pData)
2016 delete[] reinterpret_cast<char*>(pData);
2021 _WebImpl::ConvertErrorCode(int error)
2023 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
2027 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
2029 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
2031 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
2033 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
2035 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
2037 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
2039 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
2041 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
2043 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
2045 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
2047 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
2049 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
2051 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
2053 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
2054 errorCode = WEB_NO_CONNECTION;
2057 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
2059 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
2060 errorCode = WEB_BAD_URL;
2063 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
2064 errorCode = WEB_FILE_ACCESS_FAILED;
2067 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
2068 errorCode = WEB_REQUEST_TIMEOUT;
2071 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
2072 errorCode = WEB_MIME_NOT_SUPPORTED;
2075 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
2076 errorCode = WEB_OUT_OF_MEMORY;
2079 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
2080 errorCode = WEB_REQUEST_MAX_EXCEEDED;
2083 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
2085 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
2087 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
2089 case EWK_ERROR_NETWORK_STATUS_OK:
2091 case EWK_ERROR_NETWORK_STATUS_CREATED:
2093 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
2095 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
2097 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
2099 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
2101 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
2103 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
2105 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
2107 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
2109 case EWK_ERROR_NETWORK_STATUS_FOUND:
2111 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
2113 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
2115 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
2117 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
2119 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
2120 errorCode = WEB_HTTP_RESPONSE;
2123 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
2124 errorCode = WEB_INVALID_CERTIFICATE;
2128 errorCode = WEB_ERROR_UNKNOWN;
2137 _WebImpl::FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
2139 result r = E_SUCCESS;
2141 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
2142 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
2143 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
2144 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2146 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
2147 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2148 pErrorCode.release();
2150 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
2151 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2152 pErrorDescription.release();
2154 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
2155 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2156 pEventArg.release();
2163 _WebImpl::OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
2165 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
2167 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2168 String msg(pMessage);
2170 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
2171 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2175 ewk_view_javascript_alert_reply(pView);
2181 _WebImpl::OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
2183 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
2185 result r = E_SUCCESS;
2186 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2187 String msg(pMessage);
2189 r = pImpl->ShowUserConfirmPopup(USER_SCRIPT_CONFIRM, pView, msg);
2190 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2197 _WebImpl::OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
2199 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
2201 result r = E_SUCCESS;
2202 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2204 String msg(pMessage);
2205 String defVal(pDefaultValue);
2207 r = pImpl->ShowPromptPopup(msg, defVal);
2208 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2213 ewk_view_javascript_prompt_reply(pView, null);
2220 _WebImpl::OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
2222 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2223 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
2224 SysAssertf(pImpl && pPolicy, "Failed to request");
2226 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
2228 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
2230 if (pImpl->__isCertificateRequested)
2232 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->__isCertificateConfirmed));
2235 pImpl->__isCertificateRequested = true;
2237 result r = E_SUCCESS;
2239 std::unique_ptr<DbEnumerator> pEnum;
2241 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
2242 String table(CERTIFICATE_TABLE_NAME);
2245 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
2247 r = db.Construct(certificatePath, "r", null);
2248 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2250 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
2253 r = pEnum->MoveNext();
2254 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2257 r = pEnum->GetIntAt(0, allow);
2258 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2260 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
2262 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
2263 pImpl->__isCertificateConfirmed = static_cast < bool >(allow);
2267 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
2269 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
2270 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2272 ewk_view_resume(pWebCore->GetWebNativeNode());
2277 pImpl->__isCertificateRequested = true;
2281 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
2282 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
2284 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
2285 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
2294 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
2295 pImpl->__isCertificateConfirmed = false;
2297 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
2298 ewk_view_resume(pWebCore->GetWebNativeNode());
2303 _WebImpl::OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
2305 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2306 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
2307 SysAssertf(pImpl && pChallenge, "Failed to request");
2309 result r = E_SUCCESS;
2311 r = pImpl->HttpAuthenticationRequested(pChallenge);
2312 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2316 ewk_auth_challenge_credential_cancel(pChallenge);
2317 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
2322 _WebImpl::OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
2324 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2325 SysAssertf(pImpl , "Failed to request");
2327 if (pImpl->__pUserLoadingListener)
2329 result r = E_SUCCESS;
2331 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
2332 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2334 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
2335 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2336 pEventArg.release();
2341 _WebImpl::OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
2343 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2344 SysAssertf(pImpl , "Failed to request");
2346 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
2348 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
2349 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2351 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
2352 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2359 _WebImpl::OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
2361 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2362 SysAssertf(pImpl , "Failed to request");
2364 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
2366 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
2367 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2369 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
2370 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2377 _WebImpl::OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
2379 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2380 SysAssertf(pImpl , "Failed to request");
2382 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
2384 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
2385 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2387 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
2388 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2395 _WebImpl::OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
2397 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2398 SysAssertf(pImpl , "Failed to request");
2400 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
2402 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
2403 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2405 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
2406 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
2413 _WebImpl::OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
2415 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2416 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
2417 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
2419 if (pImpl->GetSetting().IsGeolocationEnabled())
2421 result r = E_SUCCESS;
2423 std::unique_ptr<DbEnumerator> pEnum;
2425 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
2426 String table(GEOLOCATION_TABLE_NAME);
2429 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
2430 String origin = _Utility::CreateOrigin(pSecurityOrigin);
2432 r = db.Construct(geolocationPath, "r", null);
2433 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2435 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
2438 r = pEnum->MoveNext();
2439 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2442 r = pEnum->GetIntAt(0, permission);
2443 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2445 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
2447 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
2451 ewk_geolocation_permission_request_suspend(pPermissionRequest);
2453 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
2454 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2461 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
2466 _WebImpl::OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
2468 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2469 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
2470 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
2472 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
2473 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2477 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
2482 _WebImpl::OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
2484 result r = E_SUCCESS;
2485 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2487 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
2488 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
2490 ewk_notification_permission_request_suspend(pPermissionRequest);
2492 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
2493 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2497 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
2502 _WebImpl::OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
2504 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2505 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
2506 SysAssertf(pImpl && pNotification, "Failed to request");
2508 result r = E_SUCCESS;
2509 Ewk_Context* pContext = ewk_view_context_get(pView);
2510 SysAssertf(pContext, "Failed to get webkit instance.");
2511 uint64_t notificationId = ewk_notification_id_get(pNotification);
2513 //ewk_notification_security_origin_get(pNotification)
2515 const char* text = ewk_notification_body_get(pNotification);
2516 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
2518 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
2519 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2521 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
2522 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
2524 pNotificationWindow->SetText(String(text));
2525 pNotificationWindow->LaunchNotification();
2526 pImpl->SetWebNotification(pNotificationWindow.release());
2528 ewk_notification_showed(pContext, notificationId);
2533 _WebImpl::OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
2535 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2536 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
2537 SysAssertf(pImpl && pNotificationID, "Failed to request");
2539 //ToDo : Where is ewk API for cancel operation?
2544 _WebImpl::OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
2546 result r = E_SUCCESS;
2547 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2548 SysAssertf(pImpl, "Failed to request");
2550 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
2551 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2556 _WebImpl::OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
2558 int checkHandler = 0;
2559 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2560 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
2561 SysAssertf(pImpl && pHandlerData, "Failed to request");
2563 checkHandler = pImpl->SearchHandler(pHandlerData, false);
2564 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2565 switch (checkHandler)
2570 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
2573 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
2576 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
2584 _WebImpl::OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
2586 result r = E_SUCCESS;
2587 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2588 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
2589 SysAssertf(pImpl && pHandlerData, "Failed to request");
2591 r = pImpl->UnregistrationHandler(pHandlerData, false);
2592 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2597 _WebImpl::OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
2599 result r = E_SUCCESS;
2600 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2601 SysAssertf(pImpl, "Failed to request");
2603 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
2604 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2609 _WebImpl::OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
2611 int checkHandler = 0;
2612 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2613 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
2614 SysAssertf(pImpl && pHandlerData, "Failed to request");
2616 checkHandler = pImpl->SearchHandler(pHandlerData, true);
2617 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2619 switch (checkHandler)
2624 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
2627 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
2630 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
2639 _WebImpl::OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
2641 result r = E_SUCCESS;
2642 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2643 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
2644 SysAssertf(pImpl && pHandlerData, "Failed to request");
2646 r = pImpl->UnregistrationHandler(pHandlerData, true);
2647 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2652 _WebImpl::OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo)
2654 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2655 SysAssertf(pImpl, "Failed to request");
2660 _WebImpl::OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
2662 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2663 SysAssertf(pImpl, "Failed to request");
2668 _WebImpl::OnVibrationRequested(uint64_t duration, void* pUserData)
2670 result r = E_SUCCESS;
2672 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2673 SysAssertf(pImpl, "Failed to request");
2675 r = pImpl->VibrationRequested(duration);
2676 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2681 _WebImpl::OnVibrationCanceled(void* pUserData)
2683 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
2684 SysAssertf(pImpl, "Failed to request");
2686 pImpl->VibrationCanceled();
2691 _WebImpl::OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
2693 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2694 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
2695 SysAssertf(pImpl && pPolicy, "Failed to request");
2697 String url(ewk_policy_decision_url_get(pPolicy));
2698 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
2700 if (url == L"about:blank")
2702 ewk_policy_decision_use(pPolicy);
2706 if (pImpl->__pUserLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
2707 && !pImpl->__isRedirectRequested)
2709 pImpl->__isCertificateRequested = false;
2711 if (pImpl->__pTextSearchListener)
2713 pImpl->__textSearch.__searchAll = false;;
2716 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
2717 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
2719 switch (ewkNavigationType)
2721 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
2722 navigationType = WEB_NAVIGATION_LINK_CLICKED;
2724 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
2725 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
2727 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
2728 navigationType = WEB_NAVIGATION_BACKFORWARD;
2730 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
2731 navigationType = WEB_NAVIGATION_RELOAD;
2733 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
2734 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
2736 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
2742 if (pImpl->__pUserLoadingListener->OnLoadingRequested(url, navigationType))
2744 ewk_policy_decision_ignore(pPolicy);
2750 String currentUrl(pImpl->GetUrl());
2751 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
2752 if (redirectUrl != L"")
2754 pImpl->LoadUrl(redirectUrl);
2755 ewk_policy_decision_ignore(pPolicy);
2763 String uriScheme(uri.GetScheme());
2764 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
2766 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
2768 ewk_policy_decision_ignore(pPolicy);
2770 if (uriScheme == L"")
2775 result r = E_SUCCESS;
2777 if (uriScheme == L"tel")
2779 String operationId(L"http://tizen.org/appcontrol/operation/dial");
2780 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
2782 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
2784 String operationId(L"http://tizen.org/appcontrol/operation/compose");
2785 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
2789 String operationId(L"http://tizen.org/appcontrol/operation/view");
2790 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
2792 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2797 ewk_policy_decision_use(pPolicy);
2802 _WebImpl::OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
2804 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2805 SysAssertf(pImpl, "Failed to request");
2807 if (pImpl->__pUserLoadingListener)
2809 result r = E_SUCCESS;
2811 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
2812 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2814 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
2815 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2816 pEventArg.release();
2822 _WebImpl::OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
2824 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2825 char* pTitle = reinterpret_cast< char* >(pEventInfo);
2826 SysAssertf(pImpl, "Failed to request");
2828 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
2830 if (pImpl->__pUserLoadingListener)
2832 result r = E_SUCCESS;
2834 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
2835 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
2836 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2838 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
2839 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2840 pPageTitle.release();
2842 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
2843 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2844 pEventArg.release();
2850 _WebImpl::OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
2852 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2853 double* pProgress = reinterpret_cast< double* >(pEventInfo);
2854 SysAssertf(pImpl, "Failed to request");
2856 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
2858 if (pImpl->__pUserLoadingListener)
2860 result r = E_SUCCESS;
2862 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
2863 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
2864 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2866 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
2867 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2868 pProgressPercentage.release();
2870 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
2871 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2872 pEventArg.release();
2878 _WebImpl::OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
2880 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2881 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
2882 SysAssertf(pImpl && pPolicy, "Failed to request");
2884 result r = E_SUCCESS;
2886 _SystemResource* pSysResource = _SystemResource::GetInstance();
2887 SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
2889 int code = ewk_policy_decision_response_status_code_get(pPolicy);
2890 String url(ewk_policy_decision_url_get(pPolicy));
2891 String mime(ewk_policy_decision_response_mime_get(pPolicy));
2892 SysSecureLog(NID_WEB_CTRL, "code : %d, url : %ls, mime : %ls", code, url.GetPointer(), mime.GetPointer());
2894 if (pImpl->__pUserLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
2896 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
2898 DecisionPolicy policy;
2899 HttpHeader httpHeader;
2901 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
2903 pImpl->__isRedirectRequested = true;
2907 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
2908 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2910 policy = pImpl->__pUserLoadingListener->OnWebDataReceived(mime, httpHeader);
2911 pImpl->__policy = policy;
2914 switch (pImpl->__policy)
2916 case WEB_DECISION_CONTINUE:
2918 String currentUrl(pImpl->GetUrl());
2919 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
2920 if (redirectUrl != L"")
2922 pImpl->LoadUrl(redirectUrl);
2923 ewk_policy_decision_ignore(pPolicy);
2928 if (pImpl->IsMimeSupported(mime) || mime == L"")
2935 ewk_policy_decision_ignore(pPolicy);
2937 String operationId(L"http://tizen.org/appcontrol/operation/view");
2939 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
2940 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
2942 if (r == E_OBJ_NOT_FOUND)
2944 _SelectBox* pSelectBox = new (std::nothrow) _SelectBox;
2945 SysTryReturnVoidResult(NID_WEB_CTRL, pSelectBox, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2947 r = pSelectBox->Construct(false, L"Select application", 1, null, url);
2948 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2950 pSelectBox->AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
2951 r = pSelectBox->ShowPopup();
2952 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2959 case WEB_DECISION_DOWNLOAD:
2961 ewk_policy_decision_ignore(pPolicy);
2963 SysTryReturnVoidResult(NID_WEB_CTRL, pImpl->__pWebDownloadHandler.get(), E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
2965 Ewk_Context* pContext = ewk_view_context_get(pView);
2966 SysAssertf(pContext, "Failed to get webkit instance.");
2968 pImpl->__pWebDownloadHandler.get()->StartDownload(url);
2972 case WEB_DECISION_IGNORE:
2974 ewk_policy_decision_ignore(pPolicy);
2984 ewk_policy_decision_use(pPolicy);
2989 ewk_policy_decision_ignore(pPolicy);
2994 _WebImpl::OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
2996 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2997 SysAssertf(pImpl, "Failed to request");
2999 if (pImpl->__isRedirectRequested)
3001 pImpl->__isRedirectRequested = false;
3004 if (pImpl->__isLoadingErrorOccurred)
3006 pImpl->__isLoadingErrorOccurred = false;
3007 evas_object_smart_callback_call(pView, "load,finished", NULL);
3013 _WebImpl::OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
3015 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3016 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
3017 SysAssertf(pImpl && pErrorData, "Failed to request");
3019 int code = ewk_error_code_get(pErrorData);
3020 const char* pDescription = ewk_error_description_get(pErrorData);
3022 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
3026 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
3027 pImpl->__isLoadingErrorOccurred = true;
3030 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
3031 evas_object_smart_callback_call(pView, "load,finished", NULL);
3034 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
3035 pImpl->__isLoadingErrorOccurred = true;
3036 evas_object_smart_callback_call(pView, "load,stop", NULL);
3040 pImpl->__isLoadingErrorOccurred = true;
3041 if (pImpl->__pUserLoadingListener)
3043 result r = E_SUCCESS;
3045 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
3046 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3054 _WebImpl::OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
3056 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3057 SysAssertf(pImpl, "Failed to request");
3059 if (pImpl->__pUserLoadingListener)
3061 result r = E_SUCCESS;
3063 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
3064 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3066 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3067 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3068 pEventArg.release();
3075 _WebImpl::OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
3077 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3078 SysAssertf(pImpl, "Failed to request");
3080 if (pImpl->__pUserLoadingListener)
3082 result r = E_SUCCESS;
3084 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
3085 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3087 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3088 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3089 pEventArg.release();
3096 _WebImpl::OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
3098 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3099 SysAssertf(pImpl, "Failed to request");
3101 if (pImpl->__pUserLoadingListener)
3103 result r = E_SUCCESS;
3105 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
3106 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3108 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3109 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3110 pEventArg.release();
3117 _WebImpl::OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
3119 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3120 SysAssertf(pUrl && pImpl != null, "Failed to request");
3122 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
3127 _WebImpl::FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
3129 result r = E_SUCCESS;
3131 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
3132 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3134 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3135 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3136 pEventArg.release();
3143 _WebImpl::OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
3145 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3146 SysAssertf(pImpl, "Failed to request");
3148 if (pImpl->__pUserUiListener)
3150 result r = E_SUCCESS;
3152 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
3153 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3155 if (pImpl->__pUserUiListenerF)
3157 result r = E_SUCCESS;
3159 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
3160 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3166 _WebImpl::OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
3168 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
3169 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
3170 SysAssertf(pParentImpl && pChildView, "Failed to request");
3172 if (pParentImpl->__pUserUiListener)
3174 Web* pWeb = pParentImpl->__pUserUiListener->OnWebWindowCreateRequested();
3177 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
3178 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
3180 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
3181 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
3184 if (pParentImpl->__pUserUiListenerF)
3186 Web* pWeb = pParentImpl->__pUserUiListenerF->OnWebWindowCreateRequested();
3189 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
3190 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
3192 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
3193 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
3200 _WebImpl::FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
3202 result r = E_SUCCESS;
3204 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
3205 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3207 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3208 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3209 pEventArg.release();
3216 _WebImpl::OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
3218 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
3219 SysAssertf(pChildImpl, "Failed to request");
3221 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
3222 if (pParentImpl == null)
3227 if (pParentImpl->__pUserUiListener)
3229 result r = E_SUCCESS;
3231 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
3232 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3234 if (pParentImpl->__pUserUiListenerF)
3236 result r = E_SUCCESS;
3238 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
3239 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3245 _WebImpl::FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
3247 result r = E_SUCCESS;
3249 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
3250 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
3251 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
3253 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
3254 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3255 pPreventTrigger.release();
3257 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3258 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3259 pEventArg.release();
3266 _WebImpl::OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
3268 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3269 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
3270 SysAssertf(pImpl && pTrigger, "Failed to request");
3272 if (pImpl->__pUserUiListener)
3274 result r = E_SUCCESS;
3276 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
3277 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3279 if (pImpl->__pUserUiListenerF)
3281 result r = E_SUCCESS;
3283 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
3284 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3290 _WebImpl::FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
3292 result r = E_SUCCESS;
3294 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
3295 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
3296 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3298 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
3300 if ((endPoint->x != 0) && (endPoint->y != 0))
3302 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
3303 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3305 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
3306 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3307 startPoint.release();
3309 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
3310 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3313 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3314 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3315 pEventArg.release();
3323 _WebImpl::FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
3325 result r = E_SUCCESS;
3327 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
3328 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
3330 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3332 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
3334 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
3336 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
3337 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3339 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
3340 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3341 startPoint.release();
3343 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
3344 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3347 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3348 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3349 pEventArg.release();
3357 _WebImpl::OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
3359 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3360 SysAssertf(pImpl, "Failed to request");
3362 if (pImpl->__pUserUiListener)
3364 result r = E_SUCCESS;
3366 r = FireWebPageBlockSelectedEvent(pImpl);
3367 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3369 if (pImpl->__pUserUiListenerF)
3371 result r = E_SUCCESS;
3373 r = FireWebPageBlockSelectedEventF(pImpl);
3374 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3380 _WebImpl::OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
3382 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
3383 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3385 pMediaListener->Construct(pView);
3388 result r = extraData.Construct();
3389 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_TRUE, r, "[%s] Propagating.", GetErrorMessage(r));
3391 String isMultipleSelection(L"single");
3392 String mode(L"selectionType");
3393 String type(L"type");
3394 String fileType = L"*/*";
3395 String operationId = L"http://tizen.org/appcontrol/operation/pick";
3399 isMultipleSelection.Append(L"multiple");
3402 if (eina_list_count(pAcceptTypes) == 1)
3404 String item((char*)eina_list_nth(pAcceptTypes, 0));
3405 String captureString(pCapture);
3407 if (item.StartsWith("image/",0))
3409 if (captureString == L"camera")
3411 fileType = L"image/jpg";
3412 operationId = L"http://tizen.org/appcontrol/operation/create_content";
3413 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
3414 String typeVal = L"false";
3415 extraData.Add(&typeKey, &typeVal);
3419 fileType = L"image/*";
3420 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
3421 extraData.Add(&selectKey, &isMultipleSelection);
3424 else if (item.StartsWith("audio/",0))
3426 fileType = L"audio/*";
3427 //TO DO: as microphone is not supported yet. suggest to throw an exception
3428 //if (captureString == L"microphone")
3430 //operationId = L"http://tizen.org/appcontrol/operation/create_content";
3434 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
3435 extraData.Add(&selectKey, &isMultipleSelection);
3438 else if (item.StartsWith("video/",0))
3440 if (captureString == L"camcorder")
3442 fileType = L"video/3gpp";
3443 operationId = L"http://tizen.org/appcontrol/operation/create_content";
3444 String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
3445 String typeVal = L"false";
3446 extraData.Add(&typeKey, &typeVal);
3450 fileType = L"video/*";
3451 String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
3452 extraData.Add(&selectKey, &isMultipleSelection);
3457 r = _AppControlImpl::FindAndStart(operationId, null, &fileType, null, &extraData, pMediaListener.get());
3458 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3460 pMediaListener.release();
3465 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
3471 _WebImpl::OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
3473 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3474 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
3475 SysAssertf(pImpl && pJsonText, "Failed to request");
3477 result r = E_SUCCESS;
3479 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
3481 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
3482 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3484 r = pEventArg->Construct(pJsonText);
3485 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3487 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3488 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3489 pEventArg.release();
3494 _WebImpl::OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
3496 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3497 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
3498 SysAssertf(pImpl && pEinaRect, "Failed to request");
3500 if (pImpl->IsVisible() == false)
3502 evas_object_focus_set(pView, EINA_FALSE);
3505 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
3507 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
3508 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
3510 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
3512 if (rect.height == 0)
3517 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
3520 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
3522 if (pFormImpl->HasFooter())
3524 pFormImpl->GetCore().SetKeypadShowState(true);
3529 if (pImpl->__pUserKeypadEventListener)
3531 if (pImpl->__isKeypadVisible)
3533 if ((pImpl->__previousKeypadBounds.width == rect.width) && (pImpl->__previousKeypadBounds.height != rect.height))
3535 pImpl->__pUserKeypadEventListener->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
3540 pImpl->__pUserKeypadEventListener->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
3543 pImpl->__isKeypadVisible = true;
3544 pImpl->__previousKeypadBounds = rect;
3548 result r = pImpl->SetFullScreenKeypad();
3549 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3555 _WebImpl::OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
3557 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3558 SysAssertf(pImpl, "Failed to request");
3560 if (pImpl->__pUserKeypadEventListener)
3562 pImpl->__pUserKeypadEventListener->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
3568 _WebImpl::OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
3570 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3571 SysAssertf(pImpl, "Failed to request");
3573 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
3576 pFormImpl->DeflateClientRectHeight(0);
3578 if (pFormImpl->HasFooter())
3580 pFormImpl->GetCore().SetKeypadShowState(false);
3585 if (pImpl->__pUserKeypadEventListener)
3587 pImpl->__pUserKeypadEventListener->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
3590 pImpl->__isKeypadVisible = false;
3595 _WebImpl::OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
3597 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3598 SysAssertf(pImpl, "Failed to request");
3600 if (pImpl->__isKeypadOpened && pImpl->IsVisible() && pImpl->IsFocused())
3602 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
3603 SysAssertf(pWebCore, "Failed to get Web core object");
3605 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
3607 pImpl->__isKeypadVisible = true;
3613 _WebImpl::OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
3615 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3616 SysAssertf(pImpl, "Failed to request");
3618 if (pImpl->__isKeypadOpened)
3620 pImpl->__isKeypadOpened = false;
3626 _WebImpl::OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
3628 SysAssertf(pSmartData, "invalid smartdata");
3629 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3630 SysAssertf(pWebImpl, "Failed to get Impl");
3632 result r = E_SUCCESS;
3634 if (pWebImpl->__pColorPicker.get())
3641 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
3642 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
3644 byte r1, g1, b1, a1;
3645 color.GetColorComponents(r1, g1, b1, a1);
3646 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
3653 _WebImpl::OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
3655 SysAssertf(pSmartData, "invalid smartdata");
3657 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3658 SysAssertf(pWebImpl, "Failed to get Impl");
3660 return pWebImpl->HideColorPicker();
3665 _WebImpl::OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
3667 SysAssertf(pSmartData, "Failed to request");
3668 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3669 SysAssertf(pWebImpl, "Failed to get Impl");
3671 result r = E_SUCCESS;
3673 if (pWebImpl->__pDatePicker.get())
3675 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
3682 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
3683 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
3685 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
3686 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3688 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
3695 _WebImpl::OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
3697 SysAssertf(pSmartData, "Failed to request");
3699 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3700 SysAssertf(pWebImpl, "Failed to get Impl");
3702 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
3703 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
3710 _WebImpl::OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
3712 SysAssertf(pSmartData, "Failed to request");
3714 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3715 SysAssertf(pWebImpl, "Failed to get Impl");
3717 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
3718 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
3725 _WebImpl::OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
3727 SysAssertf(pSmartData, "invalid smartdata");
3729 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3730 SysAssertf(pWebImpl, "Failed to get Impl");
3732 result r = pWebImpl->ClearSelectBoxPopup();
3733 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
3740 _WebImpl::OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
3742 SysAssertf(pSmartData, "invalid smartdata");
3744 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3745 SysAssertf(pWebImpl, "Failed to get Impl");
3747 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
3748 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
3755 _WebImpl::OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
3757 SysAssertf(pSmartData, "Failed to request");
3759 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3760 SysAssertf(pWebImpl, "Failed to get Impl");
3762 Rectangle windowRect(x, y, w, h);
3763 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
3764 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
3771 _WebImpl::OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
3773 SysAssertf(pSmartData, "Failed to request");
3775 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3776 SysAssertf(pWebImpl, "Failed to get Impl");
3778 if (pWebImpl->__isFormDataVisible)
3780 pWebImpl->HideFormDataWindow();
3788 _WebImpl::OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
3790 SysAssertf(pSmartData, "Failed to request");
3792 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3793 SysAssertf(pWebImpl, "Failed to get Impl");
3795 pWebImpl->SetFormDataList(pDataList);
3802 _WebImpl::OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
3804 SysAssertf(pSmartData, "Failed to request");
3806 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
3807 SysAssertf(pWebImpl, "Failed to get Impl");
3809 if (pWebImpl->__isFormDataVisible)
3821 _WebImpl::OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
3823 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
3824 SysAssertf(pPresenter && !pError, "Failed to request");
3826 bool ret = EINA_TRUE;
3830 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
3832 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
3836 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
3845 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
3847 pPresenter->EndAsyncProcess(ret);
3852 _WebImpl::OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
3854 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
3855 SysAssertf(pPresenter, "Failed to request");
3857 String result(pResult);
3858 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
3860 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
3861 _WebManager* pWebManager = _WebManager::GetInstance();
3862 if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
3864 pPresenter->EndAsyncProcess(result);
3870 _WebImpl::OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
3872 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
3873 SysAssertf(pImpl, "Failed to request");
3875 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
3876 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
3878 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
3882 pWebPresenter->EndAsyncProcess(*pTotalCount);
3886 if (pImpl->__pTextSearchListener)
3888 result r = E_SUCCESS;
3892 if (*pTotalCount > 0)
3894 ordinal = pImpl->GetAsyncSearchOrdinal();
3895 pImpl->SetAsyncSearchResult(*pTotalCount);
3898 if (pImpl->GetPendingAsyncSearchCount() > 0)
3903 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
3904 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
3905 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
3906 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3908 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
3909 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3912 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
3913 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3916 r = pImpl->__pWebEvent->FireAsync(*pEventArg.get());
3917 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3918 pEventArg.release();
3926 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
3928 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
3929 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
3931 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
3932 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3934 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
3935 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
3937 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
3944 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
3946 result r = E_SUCCESS;
3948 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
3949 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3951 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3953 ILoadingListener* pLoadingListner = GetLoadingListener();
3954 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
3956 switch (pEventArg->GetEventType())
3958 case WEB_EVENT_LOADINGLISTENER_STARTED:
3960 pLoadingListner->OnLoadingStarted();
3964 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
3966 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
3967 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3969 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
3973 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
3975 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
3976 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3978 pLoadingListner->OnPageTitleReceived(*pPageTitle);
3982 case WEB_EVENT_LOADINGLISTENER_CANCELED:
3984 pLoadingListner->OnLoadingCanceled();
3988 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
3990 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
3991 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3993 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
3994 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3996 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
3998 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4002 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4004 pLoadingListner->OnLoadingCompleted();
4008 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4010 pLoadingListner->OnHttpAuthenticationCanceled();
4014 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4016 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4017 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4021 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4037 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4039 result r = E_SUCCESS;
4041 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4042 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4044 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4046 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4047 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4049 switch (pEventArg->GetEventType())
4051 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4053 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4054 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4056 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4060 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4062 pWebDownloadListener->OnWebDataDownloadCompleted();
4066 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4068 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4069 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4071 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4073 pWebDownloadListener->OnWebDownloadFailed(errorType);
4088 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4090 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4091 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4093 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4095 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4097 switch (pEventArg->GetEventType())
4099 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4101 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4103 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4104 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4106 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4107 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4109 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4113 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4115 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4117 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4121 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4123 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4125 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4129 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4131 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4133 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4134 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4136 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4151 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4153 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4154 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4156 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4158 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4160 switch (pEventArg->GetEventType())
4162 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4164 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4166 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4167 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4169 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4170 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4172 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4176 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4178 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4180 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4184 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4186 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4188 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4192 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4194 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4196 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4197 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4199 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4214 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4216 result r = E_SUCCESS;
4218 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4219 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4221 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4223 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4224 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4226 switch (pEventArg->GetEventType())
4228 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4230 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4231 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4233 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4234 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4236 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4251 _WebImpl::VibrationRequested(uint64_t duration)
4253 result r = E_SUCCESS;
4255 __pVibrator.reset();
4257 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4258 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4260 r = pVibrator->Construct();
4261 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4263 __pVibrator = std::move(pVibrator);
4265 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4267 r = __pVibrator->Start(&pattern, 1, 1);
4268 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4275 _WebImpl::VibrationCanceled(void)
4277 __pVibrator.reset();
4282 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4284 result r = E_SUCCESS;
4286 String host(ewk_auth_challenge_url_get(pChallenge));
4287 String realm(ewk_auth_challenge_realm_get(pChallenge));
4289 __pAuthChallenge.reset();
4291 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4292 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4294 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4295 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4297 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4298 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4300 __pAuthChallenge = std::move(pAuthChallenge);
4302 ewk_auth_challenge_suspend(pChallenge);
4303 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4305 __pAuthChallenge.release();
4309 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4310 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4318 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
4320 __pSelectBox.reset();
4322 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
4324 result r = E_SUCCESS;
4326 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
4327 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4329 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
4330 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4332 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
4333 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4335 __pSelectBox = std::move(pSelectBox);
4337 __pSelectBox->SetOwner(&GetPublic());
4339 return __pSelectBox->ShowPopup();
4344 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
4346 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
4348 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
4353 _WebImpl::ClearSelectBoxPopup(void)
4355 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
4357 __pSelectBox.reset();
4364 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4366 result r = E_SUCCESS;
4368 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4369 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4371 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4372 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4374 __pAuthPopup = std::move(pAuthPopup);
4376 int modalResult = 0;
4378 r = __pAuthPopup->ShowAndWait(modalResult);
4379 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4384 __pAuthPopup.reset();
4392 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4394 result r = E_SUCCESS;
4396 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4397 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4399 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy, this);
4400 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4402 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4404 int modalResult = 0;
4406 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4407 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4409 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4411 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4415 if (__pCertConfirmPopup.get())
4417 __pCertConfirmPopup.reset();
4425 _WebImpl::ShowPromptPopup(String msg, String defVal)
4427 result r = E_SUCCESS;
4429 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4430 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4432 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
4433 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4435 __pPromptPopup = std::move(pPromptPopup);
4437 r = __pPromptPopup->ShowPopup();
4438 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4443 __pPromptPopup.reset();
4451 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4453 result r = E_SUCCESS;
4455 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4456 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4458 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg);
4459 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4461 int modalResult = 0;
4463 switch(userConfirmMode)
4465 case USER_CONTENT_HANDLER:
4467 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4469 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4470 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4472 __pContentHandlerConfirmPopup.reset();
4474 ewk_view_resume(__pWebCore->GetWebNativeNode());
4478 case USER_PROTOCOL_HANDLER:
4480 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4482 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4483 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4485 __pProtocolHandlerConfirmPopup.reset();
4487 ewk_view_resume(__pWebCore->GetWebNativeNode());
4491 case USER_CONFIRM_APP_CACHE:
4493 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4495 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4496 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4498 __pAppCacheConfirmPopup.reset();
4500 ewk_view_resume(__pWebCore->GetWebNativeNode());
4504 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4506 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4508 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4509 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4511 __pDbQuotaConfirmPopup.reset();
4513 ewk_view_resume(__pWebCore->GetWebNativeNode());
4517 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4519 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4521 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4522 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4524 __pLocalFsQuotaConfirmPopup.reset();
4526 ewk_view_resume(__pWebCore->GetWebNativeNode());
4530 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4532 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4534 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4535 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4537 __pIndexedDbQuotaConfirmPopup.reset();
4539 ewk_view_resume(__pWebCore->GetWebNativeNode());
4543 case USER_SCRIPT_CONFIRM:
4545 __pScriptConfirmPopup = std::move(pUserConfirmPopup);
4547 r = __pScriptConfirmPopup->ShowAndWait(modalResult);
4548 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4550 __pScriptConfirmPopup.reset();
4552 ewk_view_resume(__pWebCore->GetWebNativeNode());
4565 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4567 result r = E_SUCCESS;
4569 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4570 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4572 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg);
4573 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4575 switch(userConfirmMode)
4577 case USER_CONFIRM_USERMEDIA:
4579 __pUserMediaConfirmPopup.reset();
4581 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4583 r = __pUserMediaConfirmPopup->ShowPopup();
4584 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4586 __pUserMediaConfirmPopup.release();
4589 case USER_CONFIRM_GEOLOCATION:
4591 __pGeolocationConfirmPopup.reset();
4593 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4595 r = __pGeolocationConfirmPopup->ShowPopup();
4596 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4598 __pGeolocationConfirmPopup.release();
4601 case USER_CONFIRM_NOTIFICATION:
4603 __pNotificationConfirmPopup.reset();
4605 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4607 r = __pNotificationConfirmPopup->ShowPopup();
4608 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4610 __pNotificationConfirmPopup.release();
4613 case USER_SCRIPT_ALERT:
4615 __pScriptAlertConfirmPopup.reset();
4617 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4619 r = __pScriptAlertConfirmPopup->ShowPopup();
4620 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4622 __pScriptAlertConfirmPopup.release();
4637 _WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl)
4640 _FormImpl* pFormImpl = null;
4642 _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent());
4643 if (!pParentControlImpl)
4648 pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl);
4654 return GetParentFormImpl(pParentControlImpl);
4659 _WebImpl::OnFocusGained(const _ControlImpl& source)
4661 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4662 SysAssertf(pSettings, "Failed to get webkit instance.");
4663 ewk_settings_clear_text_selection_automatically_set(pSettings, true);
4665 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_TRUE);
4672 _WebImpl::OnFocusLost(const _ControlImpl& source)
4674 if(__isKeypadVisible)
4676 __isKeypadOpened = true;
4677 __isKeypadVisible = false;
4680 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4681 SysAssertf(pSettings, "Failed to get webkit instance.");
4682 ewk_settings_clear_text_selection_automatically_set(pSettings, false);
4684 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4691 _WebImpl::HasValidNativeNode(void) const
4693 if (__pWebCore && __pWebCore->GetWebNativeNode())
4703 _WebImpl::OnPreAttachedToMainTree(void)
4705 result r = E_SUCCESS;
4707 if (IsVisible() == true)
4709 _WebManager* pWebManager = _WebManager::GetInstance();
4710 pWebManager->SetActiveWeb(this);
4713 r = __pWebCore->InitializeWebNativeNode();
4714 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4716 _ControlManager* pControlManager = _ControlManager::GetInstance();
4717 SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance.");
4718 OnChangeLayout(pControlManager->GetScreenRotation());
4720 r = InitializeSetting();
4721 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4723 r = _ContainerImpl::OnPreAttachedToMainTree();
4724 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4726 _WebManager* pWebManager = _WebManager::GetInstance();
4727 pWebManager->AddWeb(reinterpret_cast< int >(this));
4734 _WebImpl::OnDetachingFromMainTree(void)
4736 _WebManager* pWebManager = _WebManager::GetInstance();
4737 pWebManager->RemoveWeb(reinterpret_cast< int >(this));
4738 pWebManager->RemoveActiveWeb(this);
4740 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
4741 pManagerImpl->SetDownloadListener(null);
4743 RemoveEventListenerCallback();
4750 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4756 case _CONTROL_ROTATION_0:
4759 case _CONTROL_ROTATION_90:
4762 case _CONTROL_ROTATION_180:
4765 case _CONTROL_ROTATION_270:
4771 ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree);
4776 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4778 _ContainerImpl::OnChangeLayout(orientation);
4780 if (__pColorPicker.get())
4782 __pColorPicker->ChangeLayout(orientation);
4785 HideFormDataWindow();
4787 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4788 _WebNotification* pWebNotification = null;
4790 while (pEnum->MoveNext() == E_SUCCESS)
4792 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4793 pWebNotification->OnChangeLayout();
4799 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4801 _WebManager* pWebManager = _WebManager::GetInstance();
4802 if (IsVisible() == true)
4804 pWebManager->SetActiveWeb(this);
4805 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4809 pWebManager->RemoveActiveWeb(this);
4810 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4816 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4818 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
4822 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4823 __pCertConfirmPopup.reset();
4825 case ID_PROMPT_POPUP_CLOSE:
4826 __pPromptPopup.reset();
4828 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
4829 __pUserMediaConfirmPopup.reset();
4831 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
4832 __pGeolocationConfirmPopup.reset();
4834 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
4835 __pNotificationConfirmPopup.reset();
4837 case ID_USER_SCRIPT_ALERT_CLOSE:
4838 __pScriptAlertConfirmPopup.reset();
4840 case ID_USER_SCRIPT_CONFIRM_CLOSE:
4841 __pScriptConfirmPopup.reset();
4850 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4852 result r = E_SUCCESS;
4854 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4855 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4857 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4859 r = pColorHadler->Construct(colorVal, this);
4860 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4862 __pColorPicker = std::move(pColorHadler);
4864 r = __pColorPicker->ShowPopup();
4865 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4869 color = __pColorPicker->GetColor();
4875 __pColorPicker.reset();
4883 _WebImpl::HideColorPicker(void)
4885 __pColorPicker.reset();
4892 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4894 result r = E_SUCCESS;
4896 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4897 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4899 r = pInputPicker->Construct(String(inputValue), inputType, this);
4900 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4902 __pDatePicker = std::move(pInputPicker);
4904 r = __pDatePicker->ShowPopup();
4905 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4909 dateStr = __pDatePicker->GetDate();
4915 __pDatePicker.reset();
4923 _WebImpl::GetInstance(Web* pWeb)
4925 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4930 _WebImpl::GetInstance(const Web* pWeb)
4932 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4937 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4939 int checkReturn = 0;
4941 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4944 if( checkmime == true)
4946 table = CUSTOM_CONTENT_TABLE_NAME;
4950 table = CUSTOM_PROTOCOL_TABLE_NAME;
4953 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4954 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4955 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4957 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4959 result r = db.Construct(handlerPath, "r+", null);
4960 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4962 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
4963 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4967 r = pEnum->MoveNext();
4968 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4969 r = pEnum->GetIntAt(0, checkReturn);
4970 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4982 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4986 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4989 if( checkmime == true)
4991 table = CUSTOM_CONTENT_TABLE_NAME;
4995 table = CUSTOM_PROTOCOL_TABLE_NAME;
4998 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4999 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5000 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5002 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5004 result r = db.Construct(handlerPath, "r+", null);
5005 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5007 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select id From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
5008 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5012 r = pEnum->MoveNext();
5013 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5014 r = pEnum->GetIntAt(0, checkId);
5015 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5017 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5018 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5020 r = pDeleteStmt->BindInt(0, checkId);
5021 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5023 db.BeginTransaction();
5025 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5027 db.CommitTransaction();
5034 const Tizen::Base::String
5035 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5037 if (originUri == L"" || currentUri == L"")
5042 result r = E_SUCCESS;
5045 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5046 String originReplace(originUri);
5047 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5051 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5052 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5054 r = currentUri.SubString(0, found + 1, baseUri);
5055 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5057 r = db.Construct(handlerPath, "r+", null);
5058 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5060 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5061 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5065 while (pEnum->MoveNext() == E_SUCCESS)
5070 String originScheme;
5072 r = pEnum->GetStringAt(0, protocol);
5073 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5075 r = pEnum->GetStringAt(1, queryUrl);
5076 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5078 r = pEnum->GetIntAt(2, allow);
5079 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5086 String protocolScheme(protocol + L":");
5088 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5089 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5091 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5093 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5095 r = originReplace.Replace(originScheme, "");
5096 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5098 queryUrl.Replace("%s", originReplace, 0);
5099 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5111 const Tizen::Base::String
5112 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5114 if (originUri == L"" || currentUri == L"" || mime == L"")
5119 result r = E_SUCCESS;
5122 String originUrlStr = originUri;
5123 const String replaceStr = L"%s";
5125 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5126 String table(CUSTOM_CONTENT_TABLE_NAME);
5130 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5131 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5133 r = currentUri.SubString(0, found + 1, baseUri);
5134 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5136 r = db.Construct(handlerPath, "r+", null);
5137 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5139 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5143 r = pEnum->MoveNext();
5144 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5145 r = pEnum->GetIntAt(0, allow);
5146 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5147 r = pEnum->GetStringAt(1, contentUrl);
5148 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5156 if (contentUrl != L"")
5158 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5159 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5171 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5173 __pFormDataList = pFormDataList;
5178 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5180 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5182 if (__isFormDataVisible)
5184 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5185 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5189 __pFormDataWindow.reset();
5191 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5192 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5194 result r = pFormDataWindow->Construct(rect, this, pWebView);
5195 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5197 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5198 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5200 r = pFormDataWindow->LaunchFormDataWindow();
5201 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5203 __pFormDataWindow = std::move(pFormDataWindow);
5204 __isFormDataVisible = true;
5212 _WebImpl::HideFormDataWindow(bool delWindow)
5216 __pFormDataWindow.reset();
5219 __isFormDataVisible = false;
5224 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5226 __webNotificationList.Remove(*pWebNotification);
5231 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5233 __webNotificationList.Add(pWebNotification);
5238 _WebImpl::OnDownloadCompleted(RequestId reqId, const String &path)
5240 _ContentManagerImpl::ScanFile(path);
5244 }}} // Tizen::Web::Controls