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 <FBaseString.h>
30 #include <FUiIActionEventListener.h>
31 #include <FUiIOrientationEventListener.h>
32 #include <FUiITextEventListener.h>
33 #include <FWebCtrlILoadingListener.h>
34 #include <FUi_ContainerImpl.h>
35 #include "FWebCtrl_IWebEventListener.h"
36 #include "FWebCtrl_UserConfirmPopup.h"
37 #include "FWebCtrl_CertificateConfirmPopup.h"
39 namespace Tizen { namespace Base { namespace Collection
41 template< class KeyType, class ValueType > class HashMapT;
42 }}} // Tizen::Base::Collection
44 namespace Tizen { namespace Base { namespace Runtime
47 }}} // Tizen::Base::Runtime
49 namespace Tizen { namespace Graphics
56 namespace Tizen { namespace Net { namespace Http {
58 }}} // Tizen::Net::Http
60 namespace Tizen { namespace Sytem
65 namespace Tizen { namespace Ui
72 namespace Tizen { namespace Ui { namespace Controls
76 }}} // Tizen::Ui::Controls
78 namespace Tizen { namespace Web { namespace Json
81 }}} // Tizen::Web::Json
83 namespace Tizen { namespace Web { namespace Controls
85 class IJavaScriptBridge;
86 class ILoadingListener;
87 class ITextSearchListener;
88 class IWebDownloadListener;
89 class IWebKeypadEventListener;
90 class IWebUiEventListener;
91 class IWebUiEventListenerF;
92 class AuthenticationChallenge;
93 class HitElementResult;
94 class PageNavigationList;
101 class _JsBridgeComparer;
102 class _JsBridgeHashCodeProvider;
103 class _AuthConfirmPopup;
104 class _GeolocationConfirmPopup;
106 class _WebDataHandler;
108 class _InputPickerPopup;
113 bool __searchForward;
114 bool __caseSensitive;
118 Tizen::Base::String __text;
119 Tizen::Base::Collection::Queue __searchQueue;
129 : public Tizen::Ui::_ContainerImpl
130 , public Tizen::Ui::ITextEventListener
131 , public Tizen::Web::Controls::_IWebEventListener
134 _WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore);
136 virtual ~_WebImpl(void);
138 result Construct(void);
140 bool HasValidNativeNode(void) const;
142 result SetZoomLevel(float level);
144 float GetZoomLevel(void) const;
146 result LoadUrl(const Tizen::Base::String& url) const;
148 result LoadUrl(const Tizen::Base::String& url, const Tizen::Net::Http::HttpHeader& header);
150 result LoadUrlWithPostRequest(const Tizen::Base::String& url, const Tizen::Net::Http::HttpHeader& header, const Tizen::Base::ByteBuffer& body) const;
152 result LoadData(const Tizen::Base::String& baseUrl, const Tizen::Base::ByteBuffer& content, const Tizen::Base::String& mime, const Tizen::Base::String& encoding) const;
154 bool CanGoBack(void) const;
156 bool CanGoForward(void) const;
158 void GoBack(void) const;
160 void GoForward(void) const;
162 bool IsLoading(void) const;
164 void StopLoading(void) const;
166 void Reload(void) const;
168 result AddCustomHeader(const Tizen::Net::Http::HttpHeader& header);
170 void RemoveAllCustomHeaders(void);
172 bool SearchText(const Tizen::Base::String& word, bool searchForward);
174 result SetSetting(const Tizen::Web::Controls::WebSetting& setting);
176 Tizen::Web::Controls::WebSetting GetSetting(void) const;
178 Tizen::Base::String GetUrl(void) const;
180 Tizen::Base::String GetTitle(void) const;
182 result SetBlockSelectionPosition(const Tizen::Graphics::Point& startPoint);
184 result SetBlockSelectionPosition(const Tizen::Graphics::FloatPoint& startPoint);
186 void ReleaseBlock(void);
188 void GetBlockRange(Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint) const;
190 void GetBlockRange(Tizen::Graphics::FloatPoint& startPoint, Tizen::Graphics::FloatPoint& endPoint) const;
192 Tizen::Base::String GetTextFromBlock(void) const;
194 Tizen::Base::String* EvaluateJavascriptN(const Tizen::Base::String& scriptCode) const;
196 bool IsPrivateBrowsingEnabled(void) const;
198 void SetPrivateBrowsingEnabled(bool enable);
200 void ClearHistory(void);
202 void ClearCache(void);
204 void ClearCookie(void);
206 void ClearFormData(void);
208 void ClearLoginFormData(void);
210 bool IsCookieEnabled(void) const;
212 void SetCookieEnabled(bool enable);
214 result SavePageAsPdf(const Tizen::Base::String& filePath, const Tizen::Graphics::Dimension* pSize) const;
216 bool IsMimeSupported(const Tizen::Base::String& mime) const;
218 result SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive);
220 result SearchNextAsync(bool searchForward);
222 result SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text
223 , bool searchForward, bool caseSensitive = false, _WebPresenter* pWebPresenter = null);
225 void SetAsyncSearchResult(int totalCount);
227 _WebPresenter* GetSearchPresenter(void);
229 int GetPendingAsyncSearchCount(void) const;
231 void CalculateAsyncSearchOrdinal(void);
233 int GetAsyncSearchOrdinal(void) const;
235 void DisableAsyncSearch(void);
237 void SetTextSearchListener(Tizen::Web::Controls::ITextSearchListener* pTextSearchListener);
239 void SetLoadingListener(Tizen::Web::Controls::ILoadingListener* pLoadingListener);
241 void SetWebUiEventListener(Tizen::Web::Controls::IWebUiEventListener* pUiEventListener);
243 void SetWebUiEventListenerF(Tizen::Web::Controls::IWebUiEventListenerF* pUiEventListener);
245 void SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener);
247 void SetDownloadListener(Tizen::Web::Controls::IWebDownloadListener* pDownLoadListener);
249 Tizen::Web::Controls::ILoadingListener* GetLoadingListener(void) const;
251 Tizen::Web::Controls::IWebUiEventListener* GetUiEventListener(void) const;
253 Tizen::Web::Controls::IWebUiEventListenerF* GetUiEventListenerF(void) const;
255 Tizen::Web::Controls::ITextSearchListener* GetTextSearchListener(void) const;
257 Tizen::Web::Controls::IWebKeypadEventListener* GetWebKeypadEventListener(void) const;
259 const Tizen::Web::Controls::PageNavigationList* GetBackForwardListN(void) const;
261 const Tizen::Web::Controls::HitElementResult* GetElementByPointN(const Tizen::Graphics::Point& point) const;
263 const Tizen::Web::Controls::HitElementResult* GetElementByPointN(const Tizen::Graphics::FloatPoint& point) const;
265 result AddJavaScriptBridge(const IJavaScriptBridge& jsBridge);
267 result RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge);
269 void SetScrollEnabled(bool enable);
271 bool IsScrollEnabled(void) const;
273 Tizen::Graphics::Bitmap* GetFaviconN(void) const;
279 void ScrollBy(const Tizen::Graphics::Point& diff);
281 void ScrollTo(const Tizen::Graphics::Point& dest);
283 Tizen::Graphics::Point GetScrollPosition(void) const;
285 Tizen::Graphics::Dimension GetPageSize(void) const;
287 virtual bool IsLayoutable(void) const;
289 void SetEventListenerCallback(void) const;
291 void RemoveEventListenerCallback(void) const;
293 _WebEvent* GetWebEvent(void) const;
295 _WebDataHandler* GetDownloadHandler(void) const;
297 result SetFullScreenKeypad(void);
299 void RemoveFullScreenKeypad(void);
301 void SetCurrentEvent(Tizen::Base::Runtime::IEventArg* arg);
303 void SetLoadingErrorOccurred(bool arg);
305 bool IsLoadingErrorOccurred(void) const;
307 void SetRedirectRequested(bool arg);
309 bool IsRedirectRequested(void) const;
311 void SetCertificateRequested(bool arg);
312 bool IsCertificateRequested(void) const;
313 bool IsCertificateConfirmed(void) const;
315 result VibrationRequested(uint64_t duration);
316 void VibrationCanceled(void);
318 bool IsFooterVisible(void) const;
320 void SetFooterVisibleState(bool isFooterVisible);
322 bool IsKeypadVisible(void) const;
324 void SetKeypadVisibleState(bool isKeypadVisible);
326 bool IsKeypadOpened(void) const;
328 void SetKeypadOpened(bool isKeypadOpened);
330 Tizen::Graphics::Rectangle GetPreviousKeypadBounds(void) const;
332 void SetPreviousKeypadBounds(Tizen::Graphics::Rectangle& bounds);
334 result HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge);
336 result ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision *pPolicy);
338 result ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy);
339 result ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy);
341 Tizen::Ui::Controls::_Form* GetParentFormCore(Tizen::Ui::_Control* pControlCore);
343 result ShowSelectBoxPopup(bool isMultiSelect, const Tizen::Base::String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex);
344 result UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList);
345 result ClearSelectBoxPopup(void);
347 result ShowColorPicker(int r, int g, int b, int a,Tizen::Graphics::Color& color);
348 Eina_Bool HideColorPicker(void);
349 _InputPickerPopup* GetColorpicker(void);
351 result ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue,Tizen::Base::String& dateStr);
352 _InputPickerPopup* GetDatepicker(void);
355 void SetPolicyDecision(DecisionPolicy policy);
357 DecisionPolicy GetPolicyDecision(void) const;
359 virtual bool OnFocusGained(const Tizen::Ui::_ControlImpl& source);
361 virtual bool OnFocusLost(const Tizen::Ui::_ControlImpl& source);
363 virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source);
365 virtual void OnTextValueChanged(const Tizen::Ui::Control& source);
367 virtual result OnAttachedToMainTree(void);
369 virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
371 virtual void OnAncestorVisibleStateChanged(const Tizen::Ui::_Control& control);
373 static _WebImpl* CreateWebImplN(Web* pControl, const Tizen::Graphics::Rectangle& bounds);
375 static _WebImpl* CreateWebImplN(Web* pControl, const Tizen::Graphics::FloatRectangle& bounds);
377 static _WebImpl* GetInstance(Web* pWeb);
379 static const _WebImpl* GetInstance(const Web* pWeb);
381 int SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime);
383 result UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime);
385 const Tizen::Base::String GetProtocolFromUri(const Tizen::Base::String& originuri, const Tizen::Base::String& currenturi);
387 const Tizen::Base::String GetRedirectUri(const Tizen::Base::String& originuri, const Tizen::Base::String& currenturi, const Tizen::Base::String& mime);
390 result InitializeSetting(void);
391 result InitJsBridgeList(void);
392 result InitWebEvent(void);
394 IJavaScriptBridge* FindJsInterface(const Tizen::Web::Json::IJsonValue* pValue) const;
395 result LaunchAppControl(const Tizen::Base::Runtime::IEventArg& arg);
397 result ShowAuthenticationPopup(const Tizen::Base::String& host, const Tizen::Base::String& realm, AuthenticationChallenge* pAuthChallenge);
399 Eina_Hash* ConvertToSlpHeaderN(const Tizen::Net::Http::HttpHeader& header) const;
401 result OnHandleJavaScriptRequestByEventArg(const Tizen::Base::Runtime::IEventArg& arg);
402 result OnHandleLoadingEvent(const Tizen::Base::Runtime::IEventArg& arg);
403 result OnHandleWebDownloadEvent(const Tizen::Base::Runtime::IEventArg& arg);
404 result OnHandleWebUiEvent(const Tizen::Base::Runtime::IEventArg& arg);
405 result OnHandleWebUiEventF(const Tizen::Base::Runtime::IEventArg& arg);
406 result OnHandleTextSearchEvent(const Tizen::Base::Runtime::IEventArg& arg);
409 bool __isFooterVisible;
410 bool __isKeypadVisible;
411 bool __isKeypadOpened;
412 bool __isLoadingErrorOccurred;
413 bool __isRedirectRequested;
414 bool __isCertificateRequested;
415 bool __isCertificateConfirmed;
416 Tizen::Graphics::Rectangle __keypadBounds;
420 ILoadingListener* __pUserLoadingListener;
421 IWebUiEventListener* __pUserUiListener;
422 IWebUiEventListenerF* __pUserUiListenerF;
423 IWebKeypadEventListener* __pUserKeypadEventListener;
424 ITextSearchListener* __pTextSearchListener;
426 std::unique_ptr<Tizen::Ui::Controls::Keypad> __pKeypad;
428 std::unique_ptr<Tizen::Base::Collection::HashMapT< Tizen::Base::String, IJavaScriptBridge* > > __pJsBridgeList;
429 std::unique_ptr<_JsBridgeHashCodeProvider> __pJsProvider;
430 std::unique_ptr<_JsBridgeComparer> __pJsComparer;
432 std::unique_ptr<_WebDataHandler> __pWebDownloadHandler;
434 std::unique_ptr<_WebEvent> __pWebEvent;
436 std::unique_ptr<AuthenticationChallenge> __pAuthChallenge;
437 std::unique_ptr<_AuthConfirmPopup> __pAuthPopup;
439 std::unique_ptr<_UserConfirmPopup> __pUserConfirmPopup;
441 std::unique_ptr<_CertificateConfirmPopup> __pCertConfirmPopup;
443 std::unique_ptr<_SelectBox> __pSelectBox;
444 std::unique_ptr<_InputPickerPopup> __pDatePicker;
445 std::unique_ptr<_InputPickerPopup> __pColorPicker;
447 std::unique_ptr<Tizen::System::_VibratorImpl> __pVibrator;
449 Tizen::Base::Runtime::Mutex __mutex;
451 _TextSearch __textSearch;
453 DecisionPolicy __policy;
456 }}} // Tizen::Web::Controls
457 #endif // _FWEB_CTRL_INTERNAL_WEB_IMPL_H_