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.h
20 * @brief The file contains the declaration of _WebImpl class.
22 * The file contains the declaration of _WebImpl class.
24 #ifndef _FWEB_CTRL_INTERNAL_WEB_IMPL_H_
25 #define _FWEB_CTRL_INTERNAL_WEB_IMPL_H_
27 #include <unique_ptr.h>
29 #include <FBaseColArrayList.h>
30 #include <FBaseString.h>
31 #include <FCntIDownloadListener.h>
32 #include <FUiIActionEventListener.h>
33 #include <FUiIOrientationEventListener.h>
34 #include <FUiITextEventListener.h>
35 #include <FWebCtrlILoadingListener.h>
36 #include <FUi_ContainerImpl.h>
37 #include "FWebCtrl_CertificateConfirmPopup.h"
38 #include "FWebCtrl_IWebEventListener.h"
39 #include "FWebCtrl_UserConfirmPopup.h"
41 namespace Tizen { namespace Base { namespace Collection
43 template< class KeyType, class ValueType > class HashMapT;
44 }}} // Tizen::Base::Collection
46 namespace Tizen { namespace Base { namespace Runtime
49 }}} // Tizen::Base::Runtime
51 namespace Tizen { namespace Graphics
58 namespace Tizen { namespace Net { namespace Http {
60 }}} // Tizen::Net::Http
62 namespace Tizen { namespace System
67 namespace Tizen { namespace Ui
74 namespace Tizen { namespace Ui { namespace Controls
78 }}} // Tizen::Ui::Controls
80 namespace Tizen { namespace Web { namespace Json
83 }}} // Tizen::Web::Json
85 namespace Tizen { namespace Web { namespace Controls
87 class IJavaScriptBridge;
88 class ILoadingListener;
89 class ITextSearchListener;
90 class IWebDownloadListener;
91 class IWebKeypadEventListener;
92 class IWebUiEventListener;
93 class IWebUiEventListenerF;
94 class AuthenticationChallenge;
95 class HitElementResult;
96 class PageNavigationList;
103 class _JsBridgeComparer;
104 class _JsBridgeHashCodeProvider;
105 class _AuthConfirmPopup;
107 class _GeolocationConfirmPopup;
108 class _WebDataHandler;
110 class _InputPickerPopup;
111 class _FormDataWindow;
112 class _WebNotification;
117 bool __searchForward;
118 bool __caseSensitive;
122 Tizen::Base::String __text;
123 Tizen::Base::Collection::Queue __searchQueue;
132 enum _WebPopupCloseId
134 ID_CERTIFICATE_CONFIRM_POPUP_CLOSE,
135 ID_PROMPT_POPUP_CLOSE,
136 ID_USER_CONFIRM_POPUP_CLOSE
140 : public Tizen::Ui::_ContainerImpl
141 , public Tizen::Ui::ITextEventListener
142 , public Tizen::Web::Controls::_IWebEventListener
143 , public Tizen::Content::IDownloadListener
146 _WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore);
148 virtual ~_WebImpl(void);
150 result Construct(void);
152 bool HasValidNativeNode(void) const;
154 result SetZoomLevel(float level);
156 float GetZoomLevel(void) const;
158 result LoadUrl(const Tizen::Base::String& url) const;
160 result LoadUrl(const Tizen::Base::String& url, const Tizen::Net::Http::HttpHeader& header);
162 result LoadUrlWithPostRequest(const Tizen::Base::String& url, const Tizen::Net::Http::HttpHeader& header, const Tizen::Base::ByteBuffer& body) const;
164 result LoadData(const Tizen::Base::String& baseUrl, const Tizen::Base::ByteBuffer& content, const Tizen::Base::String& mime, const Tizen::Base::String& encoding) const;
166 bool CanGoBack(void) const;
168 bool CanGoForward(void) const;
170 void GoBack(void) const;
172 void GoForward(void) const;
174 bool IsLoading(void) const;
176 void StopLoading(void) const;
178 void Reload(void) const;
180 result AddCustomHeader(const Tizen::Net::Http::HttpHeader& header);
182 void RemoveAllCustomHeaders(void);
184 bool SearchText(const Tizen::Base::String& word, bool searchForward);
186 result SetSetting(const Tizen::Web::Controls::WebSetting& setting);
188 Tizen::Web::Controls::WebSetting GetSetting(void) const;
190 Tizen::Base::String GetUrl(void) const;
192 Tizen::Base::String GetTitle(void) const;
194 result SetBlockSelectionPosition(const Tizen::Graphics::Point& startPoint);
196 result SetBlockSelectionPosition(const Tizen::Graphics::FloatPoint& startPoint);
198 void ReleaseBlock(void);
200 void GetBlockRange(Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint) const;
202 void GetBlockRange(Tizen::Graphics::FloatPoint& startPoint, Tizen::Graphics::FloatPoint& endPoint) const;
204 Tizen::Base::String GetTextFromBlock(void) const;
206 Tizen::Base::String* EvaluateJavascriptN(const Tizen::Base::String& scriptCode);
208 bool IsPrivateBrowsingEnabled(void) const;
210 void SetPrivateBrowsingEnabled(bool enable);
212 void ClearHistory(void);
214 void ClearCache(void);
216 void ClearCookie(void);
218 void ClearFormData(void);
220 void ClearLoginFormData(void);
222 bool IsCookieEnabled(void) const;
224 void SetCookieEnabled(bool enable);
226 result SavePageAsPdf(const Tizen::Base::String& filePath, const Tizen::Graphics::Dimension* pSize) const;
228 bool IsMimeSupported(const Tizen::Base::String& mime) const;
230 result SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive);
232 result SearchNextAsync(bool searchForward);
234 result SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text
235 , bool searchForward, bool caseSensitive = false, _WebPresenter* pWebPresenter = null);
237 void SetAsyncSearchResult(int totalCount);
239 _WebPresenter* GetSearchPresenter(void);
241 int GetPendingAsyncSearchCount(void) const;
243 void CalculateAsyncSearchOrdinal(void);
245 int GetAsyncSearchOrdinal(void) const;
247 void DisableAsyncSearch(void);
249 void SetTextSearchListener(Tizen::Web::Controls::ITextSearchListener* pTextSearchListener);
251 void SetLoadingListener(Tizen::Web::Controls::ILoadingListener* pLoadingListener);
253 void SetWebUiEventListener(Tizen::Web::Controls::IWebUiEventListener* pUiEventListener);
255 void SetWebUiEventListenerF(Tizen::Web::Controls::IWebUiEventListenerF* pUiEventListener);
257 void SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener);
259 void SetDownloadListener(Tizen::Web::Controls::IWebDownloadListener* pDownLoadListener);
261 Tizen::Web::Controls::ILoadingListener* GetLoadingListener(void) const;
263 Tizen::Web::Controls::IWebUiEventListener* GetUiEventListener(void) const;
265 Tizen::Web::Controls::IWebUiEventListenerF* GetUiEventListenerF(void) const;
267 Tizen::Web::Controls::ITextSearchListener* GetTextSearchListener(void) const;
269 Tizen::Web::Controls::IWebKeypadEventListener* GetWebKeypadEventListener(void) const;
271 const Tizen::Web::Controls::PageNavigationList* GetBackForwardListN(void) const;
273 const Tizen::Web::Controls::HitElementResult* GetElementByPointN(const Tizen::Graphics::Point& point) const;
275 const Tizen::Web::Controls::HitElementResult* GetElementByPointN(const Tizen::Graphics::FloatPoint& point) const;
277 result AddJavaScriptBridge(const IJavaScriptBridge& jsBridge);
279 result RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge);
281 void SetScrollEnabled(bool enable);
283 bool IsScrollEnabled(void) const;
285 Tizen::Graphics::Bitmap* GetFaviconN(void) const;
291 void ScrollBy(const Tizen::Graphics::Point& diff);
293 void ScrollTo(const Tizen::Graphics::Point& dest);
295 Tizen::Graphics::Point GetScrollPosition(void) const;
297 Tizen::Graphics::Dimension GetPageSize(void) const;
299 virtual bool IsLayoutable(void) const;
301 void SetEventListenerCallback(void) const;
303 void RemoveEventListenerCallback(void) const;
305 _WebEvent* GetWebEvent(void) const;
307 _WebDataHandler* GetDownloadHandler(void) const;
309 result SetFullScreenKeypad(void);
311 void RemoveFullScreenKeypad(void);
313 void SetCurrentEvent(Tizen::Base::Runtime::IEventArg* arg);
315 void SetLoadingErrorOccurred(bool arg);
317 bool IsLoadingErrorOccurred(void) const;
319 void SetRedirectRequested(bool arg);
321 bool IsRedirectRequested(void) const;
323 void SetCertificateRequested(bool arg);
324 bool IsCertificateRequested(void) const;
325 void SetCertificateConfirmed(bool arg);
326 bool IsCertificateConfirmed(void) const;
327 void ClearCertificateDb(void);
329 void SetOrientationChanged(bool arg);
330 bool IsOrientationChanged(void) const;
332 result VibrationRequested(uint64_t duration);
333 void VibrationCanceled(void);
335 bool IsFooterVisible(void) const;
337 void SetFooterVisibleState(bool isFooterVisible);
339 bool IsKeypadVisible(void) const;
341 void SetKeypadVisibleState(bool isKeypadVisible);
343 bool IsKeypadOpened(void) const;
345 void SetKeypadOpened(bool isKeypadOpened);
347 bool IsPresenterAlived(_WebPresenter* pPresenter) const;
348 Tizen::Graphics::Rectangle GetPreviousKeypadBounds(void) const;
350 void SetPreviousKeypadBounds(Tizen::Graphics::Rectangle& bounds);
352 result HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge);
354 result ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision *pPolicy);
356 result ShowPromptPopup(Tizen::Base::String msg = L"", Tizen::Base::String defVal = L"");
358 result ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, Tizen::Base::String msg = L"");
359 result ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, Tizen::Base::String msg = L"");
361 Tizen::Ui::Controls::_Form* GetParentFormCore(Tizen::Ui::_Control* pControlCore);
363 result ShowSelectBoxPopup(bool isMultiSelect, const Tizen::Base::String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex);
364 result UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList);
365 result ClearSelectBoxPopup(void);
367 result ShowColorPicker(int r, int g, int b, int a,Tizen::Graphics::Color& color);
368 Eina_Bool HideColorPicker(void);
369 _InputPickerPopup* GetColorpicker(void);
371 result ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue,Tizen::Base::String& dateStr);
372 _InputPickerPopup* GetDatepicker(void);
375 void SetPolicyDecision(DecisionPolicy policy);
377 DecisionPolicy GetPolicyDecision(void) const;
379 virtual bool OnFocusGained(const Tizen::Ui::_ControlImpl& source);
381 virtual bool OnFocusLost(const Tizen::Ui::_ControlImpl& source);
383 virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source);
385 virtual void OnTextValueChanged(const Tizen::Ui::Control& source);
387 virtual result OnPreAttachedToMainTree(void);
389 virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
391 virtual void OnAncestorVisibleStateChanged(const Tizen::Ui::_Control& control);
393 virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs);
395 static _WebImpl* CreateWebImplN(Web* pControl, const Tizen::Graphics::Rectangle& bounds);
397 static _WebImpl* CreateWebImplN(Web* pControl, const Tizen::Graphics::FloatRectangle& bounds);
399 static _WebImpl* GetInstance(Web* pWeb);
401 static const _WebImpl* GetInstance(const Web* pWeb);
403 int SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime);
405 result UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime);
407 const Tizen::Base::String GetProtocolFromUri(const Tizen::Base::String& originuri, const Tizen::Base::String& currenturi);
409 const Tizen::Base::String GetRedirectUri(const Tizen::Base::String& originuri, const Tizen::Base::String& currenturi, const Tizen::Base::String& mime);
411 void SetFormDataList(Eina_List* pFormDataList);
413 bool IsFormDataWindowVisible(void) const;
415 result ShowFormDataWindow(const Tizen::Graphics::Rectangle& windowRect, Evas_Object* pWebView);
417 void HideFormDataWindow(bool delWindow = true);
419 void SetWebNotification(_WebNotification* pWebNotification);
421 void ClearWebNotification(_WebNotification* pWebNotification);
424 result InitializeSetting(void);
425 result InitJsBridgeList(void);
426 result InitWebEvent(void);
428 IJavaScriptBridge* FindJsInterface(const Tizen::Web::Json::IJsonValue* pValue) const;
429 result LaunchAppControl(const Tizen::Base::Runtime::IEventArg& arg);
431 result ShowAuthenticationPopup(const Tizen::Base::String& host, const Tizen::Base::String& realm, AuthenticationChallenge* pAuthChallenge);
433 Eina_Hash* ConvertToSlpHeaderN(const Tizen::Net::Http::HttpHeader& header) const;
435 result OnHandleJavaScriptRequestByEventArg(const Tizen::Base::Runtime::IEventArg& arg);
436 result OnHandleLoadingEvent(const Tizen::Base::Runtime::IEventArg& arg);
437 result OnHandleWebDownloadEvent(const Tizen::Base::Runtime::IEventArg& arg);
438 result OnHandleWebUiEvent(const Tizen::Base::Runtime::IEventArg& arg);
439 result OnHandleWebUiEventF(const Tizen::Base::Runtime::IEventArg& arg);
440 result OnHandleTextSearchEvent(const Tizen::Base::Runtime::IEventArg& arg);
442 virtual void OnDownloadCanceled(RequestId reqId) {}
443 virtual void OnDownloadCompleted(RequestId reqId, const Tizen::Base::String &path);
444 virtual void OnDownloadFailed(RequestId reqId, result r, const Tizen::Base::String &errorCode) {}
445 virtual void OnDownloadInProgress(RequestId reqId, unsigned long long receivedSize, unsigned long long totalSize) {}
446 virtual void OnDownloadPaused(RequestId reqId) {}
449 bool __isFooterVisible;
450 bool __isKeypadVisible;
451 bool __isKeypadOpened;
452 bool __isLoadingErrorOccurred;
453 bool __isRedirectRequested;
454 bool __isCertificateRequested;
455 bool __isCertificateConfirmed;
456 bool __isOrientationChanged;
457 bool __isFormDataVisible;
458 Tizen::Graphics::Rectangle __keypadBounds;
462 ILoadingListener* __pUserLoadingListener;
463 IWebUiEventListener* __pUserUiListener;
464 IWebUiEventListenerF* __pUserUiListenerF;
465 IWebKeypadEventListener* __pUserKeypadEventListener;
466 ITextSearchListener* __pTextSearchListener;
468 std::unique_ptr<Tizen::Ui::Controls::Keypad> __pKeypad;
470 std::unique_ptr<Tizen::Base::Collection::HashMapT< Tizen::Base::String, IJavaScriptBridge* > > __pJsBridgeList;
471 std::unique_ptr<_JsBridgeHashCodeProvider> __pJsProvider;
472 std::unique_ptr<_JsBridgeComparer> __pJsComparer;
474 std::unique_ptr<_WebDataHandler> __pWebDownloadHandler;
476 std::unique_ptr<_WebEvent> __pWebEvent;
478 std::unique_ptr<AuthenticationChallenge> __pAuthChallenge;
479 std::unique_ptr<_AuthConfirmPopup> __pAuthPopup;
481 std::unique_ptr<_UserConfirmPopup> __pUserConfirmPopup;
482 std::unique_ptr< _PromptPopup > __pPromptPopup;
483 std::unique_ptr<_CertificateConfirmPopup> __pCertConfirmPopup;
485 std::unique_ptr<_SelectBox> __pSelectBox;
486 std::unique_ptr<_InputPickerPopup> __pDatePicker;
487 std::unique_ptr<_InputPickerPopup> __pColorPicker;
488 std::unique_ptr<_FormDataWindow> __pFormDataWindow;
490 std::unique_ptr<Tizen::System::_VibratorImpl> __pVibrator;
492 Tizen::Base::Runtime::Mutex __mutex;
494 _TextSearch __textSearch;
496 Tizen::Base::Collection::ArrayList __callbackList;
498 Tizen::Base::Collection::ArrayList __webNotificationList;
500 DecisionPolicy __policy;
502 Tizen::Base::String __defaultUserAgent;
504 Eina_List* __pFormDataList;
507 }}} // Tizen::Web::Controls
508 #endif // _FWEB_CTRL_INTERNAL_WEB_IMPL_H_