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 <FUiIActionEventListener.h>
32 #include <FUiIOrientationEventListener.h>
33 #include <FUiITextEventListener.h>
34 #include <FWebCtrlILoadingListener.h>
35 #include <FUi_ContainerImpl.h>
36 #include "FWebCtrl_IWebEventListener.h"
37 #include "FWebCtrl_UserConfirmPopup.h"
38 #include "FWebCtrl_CertificateConfirmPopup.h"
40 namespace Tizen { namespace Base { namespace Collection
42 template< class KeyType, class ValueType > class HashMapT;
43 }}} // Tizen::Base::Collection
45 namespace Tizen { namespace Base { namespace Runtime
48 }}} // Tizen::Base::Runtime
50 namespace Tizen { namespace Graphics
57 namespace Tizen { namespace Net { namespace Http {
59 }}} // Tizen::Net::Http
61 namespace Tizen { namespace Sytem
66 namespace Tizen { namespace Ui
73 namespace Tizen { namespace Ui { namespace Controls
77 }}} // Tizen::Ui::Controls
79 namespace Tizen { namespace Web { namespace Json
82 }}} // Tizen::Web::Json
84 namespace Tizen { namespace Web { namespace Controls
86 class IJavaScriptBridge;
87 class ILoadingListener;
88 class ITextSearchListener;
89 class IWebDownloadListener;
90 class IWebKeypadEventListener;
91 class IWebUiEventListener;
92 class IWebUiEventListenerF;
93 class AuthenticationChallenge;
94 class HitElementResult;
95 class PageNavigationList;
102 class _JsBridgeComparer;
103 class _JsBridgeHashCodeProvider;
104 class _AuthConfirmPopup;
105 class _GeolocationConfirmPopup;
107 class _WebDataHandler;
109 class _InputPickerPopup;
114 bool __searchForward;
115 bool __caseSensitive;
119 Tizen::Base::String __text;
120 Tizen::Base::Collection::Queue __searchQueue;
130 : public Tizen::Ui::_ContainerImpl
131 , public Tizen::Ui::ITextEventListener
132 , public Tizen::Web::Controls::_IWebEventListener
135 _WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore);
137 virtual ~_WebImpl(void);
139 result Construct(void);
141 bool HasValidNativeNode(void) const;
143 result SetZoomLevel(float level);
145 float GetZoomLevel(void) const;
147 result LoadUrl(const Tizen::Base::String& url) const;
149 result LoadUrl(const Tizen::Base::String& url, const Tizen::Net::Http::HttpHeader& header);
151 result LoadUrlWithPostRequest(const Tizen::Base::String& url, const Tizen::Net::Http::HttpHeader& header, const Tizen::Base::ByteBuffer& body) const;
153 result LoadData(const Tizen::Base::String& baseUrl, const Tizen::Base::ByteBuffer& content, const Tizen::Base::String& mime, const Tizen::Base::String& encoding) const;
155 bool CanGoBack(void) const;
157 bool CanGoForward(void) const;
159 void GoBack(void) const;
161 void GoForward(void) const;
163 bool IsLoading(void) const;
165 void StopLoading(void) const;
167 void Reload(void) const;
169 result AddCustomHeader(const Tizen::Net::Http::HttpHeader& header);
171 void RemoveAllCustomHeaders(void);
173 bool SearchText(const Tizen::Base::String& word, bool searchForward);
175 result SetSetting(const Tizen::Web::Controls::WebSetting& setting);
177 Tizen::Web::Controls::WebSetting GetSetting(void) const;
179 Tizen::Base::String GetUrl(void) const;
181 Tizen::Base::String GetTitle(void) const;
183 result SetBlockSelectionPosition(const Tizen::Graphics::Point& startPoint);
185 result SetBlockSelectionPosition(const Tizen::Graphics::FloatPoint& startPoint);
187 void ReleaseBlock(void);
189 void GetBlockRange(Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint) const;
191 void GetBlockRange(Tizen::Graphics::FloatPoint& startPoint, Tizen::Graphics::FloatPoint& endPoint) const;
193 Tizen::Base::String GetTextFromBlock(void) const;
195 Tizen::Base::String* EvaluateJavascriptN(const Tizen::Base::String& scriptCode);
197 bool IsPrivateBrowsingEnabled(void) const;
199 void SetPrivateBrowsingEnabled(bool enable);
201 void ClearHistory(void);
203 void ClearCache(void);
205 void ClearCookie(void);
207 void ClearFormData(void);
209 void ClearLoginFormData(void);
211 bool IsCookieEnabled(void) const;
213 void SetCookieEnabled(bool enable);
215 result SavePageAsPdf(const Tizen::Base::String& filePath, const Tizen::Graphics::Dimension* pSize) const;
217 bool IsMimeSupported(const Tizen::Base::String& mime) const;
219 result SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive);
221 result SearchNextAsync(bool searchForward);
223 result SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text
224 , bool searchForward, bool caseSensitive = false, _WebPresenter* pWebPresenter = null);
226 void SetAsyncSearchResult(int totalCount);
228 _WebPresenter* GetSearchPresenter(void);
230 int GetPendingAsyncSearchCount(void) const;
232 void CalculateAsyncSearchOrdinal(void);
234 int GetAsyncSearchOrdinal(void) const;
236 void DisableAsyncSearch(void);
238 void SetTextSearchListener(Tizen::Web::Controls::ITextSearchListener* pTextSearchListener);
240 void SetLoadingListener(Tizen::Web::Controls::ILoadingListener* pLoadingListener);
242 void SetWebUiEventListener(Tizen::Web::Controls::IWebUiEventListener* pUiEventListener);
244 void SetWebUiEventListenerF(Tizen::Web::Controls::IWebUiEventListenerF* pUiEventListener);
246 void SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener);
248 void SetDownloadListener(Tizen::Web::Controls::IWebDownloadListener* pDownLoadListener);
250 Tizen::Web::Controls::ILoadingListener* GetLoadingListener(void) const;
252 Tizen::Web::Controls::IWebUiEventListener* GetUiEventListener(void) const;
254 Tizen::Web::Controls::IWebUiEventListenerF* GetUiEventListenerF(void) const;
256 Tizen::Web::Controls::ITextSearchListener* GetTextSearchListener(void) const;
258 Tizen::Web::Controls::IWebKeypadEventListener* GetWebKeypadEventListener(void) const;
260 const Tizen::Web::Controls::PageNavigationList* GetBackForwardListN(void) const;
262 const Tizen::Web::Controls::HitElementResult* GetElementByPointN(const Tizen::Graphics::Point& point) const;
264 const Tizen::Web::Controls::HitElementResult* GetElementByPointN(const Tizen::Graphics::FloatPoint& point) const;
266 result AddJavaScriptBridge(const IJavaScriptBridge& jsBridge);
268 result RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge);
270 void SetScrollEnabled(bool enable);
272 bool IsScrollEnabled(void) const;
274 Tizen::Graphics::Bitmap* GetFaviconN(void) const;
280 void ScrollBy(const Tizen::Graphics::Point& diff);
282 void ScrollTo(const Tizen::Graphics::Point& dest);
284 Tizen::Graphics::Point GetScrollPosition(void) const;
286 Tizen::Graphics::Dimension GetPageSize(void) const;
288 virtual bool IsLayoutable(void) const;
290 void SetEventListenerCallback(void) const;
292 void RemoveEventListenerCallback(void) const;
294 _WebEvent* GetWebEvent(void) const;
296 _WebDataHandler* GetDownloadHandler(void) const;
298 result SetFullScreenKeypad(void);
300 void RemoveFullScreenKeypad(void);
302 void SetCurrentEvent(Tizen::Base::Runtime::IEventArg* arg);
304 void SetLoadingErrorOccurred(bool arg);
306 bool IsLoadingErrorOccurred(void) const;
308 void SetRedirectRequested(bool arg);
310 bool IsRedirectRequested(void) const;
312 void SetCertificateRequested(bool arg);
313 bool IsCertificateRequested(void) const;
314 bool IsCertificateConfirmed(void) const;
316 void SetOrientationChanged(bool arg);
317 bool IsOrientationChanged(void) const;
319 result VibrationRequested(uint64_t duration);
320 void VibrationCanceled(void);
322 bool IsFooterVisible(void) const;
324 void SetFooterVisibleState(bool isFooterVisible);
326 bool IsKeypadVisible(void) const;
328 void SetKeypadVisibleState(bool isKeypadVisible);
330 bool IsKeypadOpened(void) const;
332 void SetKeypadOpened(bool isKeypadOpened);
334 bool IsPresenterAlived(_WebPresenter* pPresenter) const;
335 Tizen::Graphics::Rectangle GetPreviousKeypadBounds(void) const;
337 void SetPreviousKeypadBounds(Tizen::Graphics::Rectangle& bounds);
339 result HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge);
341 result ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision *pPolicy);
343 result ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy);
344 result ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, Tizen::Base::String msg = L"");
346 Tizen::Ui::Controls::_Form* GetParentFormCore(Tizen::Ui::_Control* pControlCore);
348 result ShowSelectBoxPopup(bool isMultiSelect, const Tizen::Base::String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex);
349 result UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList);
350 result ClearSelectBoxPopup(void);
352 result ShowColorPicker(int r, int g, int b, int a,Tizen::Graphics::Color& color);
353 Eina_Bool HideColorPicker(void);
354 _InputPickerPopup* GetColorpicker(void);
356 result ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue,Tizen::Base::String& dateStr);
357 _InputPickerPopup* GetDatepicker(void);
360 void SetPolicyDecision(DecisionPolicy policy);
362 DecisionPolicy GetPolicyDecision(void) const;
364 virtual bool OnFocusGained(const Tizen::Ui::_ControlImpl& source);
366 virtual bool OnFocusLost(const Tizen::Ui::_ControlImpl& source);
368 virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source);
370 virtual void OnTextValueChanged(const Tizen::Ui::Control& source);
372 virtual result OnPreAttachedToMainTree(void);
374 virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
376 virtual void OnAncestorVisibleStateChanged(const Tizen::Ui::_Control& control);
378 static _WebImpl* CreateWebImplN(Web* pControl, const Tizen::Graphics::Rectangle& bounds);
380 static _WebImpl* CreateWebImplN(Web* pControl, const Tizen::Graphics::FloatRectangle& bounds);
382 static _WebImpl* GetInstance(Web* pWeb);
384 static const _WebImpl* GetInstance(const Web* pWeb);
386 int SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime);
388 result UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime);
390 const Tizen::Base::String GetProtocolFromUri(const Tizen::Base::String& originuri, const Tizen::Base::String& currenturi);
392 const Tizen::Base::String GetRedirectUri(const Tizen::Base::String& originuri, const Tizen::Base::String& currenturi, const Tizen::Base::String& mime);
395 result InitializeSetting(void);
396 result InitJsBridgeList(void);
397 result InitWebEvent(void);
399 IJavaScriptBridge* FindJsInterface(const Tizen::Web::Json::IJsonValue* pValue) const;
400 result LaunchAppControl(const Tizen::Base::Runtime::IEventArg& arg);
402 result ShowAuthenticationPopup(const Tizen::Base::String& host, const Tizen::Base::String& realm, AuthenticationChallenge* pAuthChallenge);
404 Eina_Hash* ConvertToSlpHeaderN(const Tizen::Net::Http::HttpHeader& header) const;
406 result OnHandleJavaScriptRequestByEventArg(const Tizen::Base::Runtime::IEventArg& arg);
407 result OnHandleLoadingEvent(const Tizen::Base::Runtime::IEventArg& arg);
408 result OnHandleWebDownloadEvent(const Tizen::Base::Runtime::IEventArg& arg);
409 result OnHandleWebUiEvent(const Tizen::Base::Runtime::IEventArg& arg);
410 result OnHandleWebUiEventF(const Tizen::Base::Runtime::IEventArg& arg);
411 result OnHandleTextSearchEvent(const Tizen::Base::Runtime::IEventArg& arg);
414 bool __isFooterVisible;
415 bool __isKeypadVisible;
416 bool __isKeypadOpened;
417 bool __isLoadingErrorOccurred;
418 bool __isRedirectRequested;
419 bool __isCertificateRequested;
420 bool __isCertificateConfirmed;
421 bool __isOrientationChanged;
422 Tizen::Graphics::Rectangle __keypadBounds;
426 ILoadingListener* __pUserLoadingListener;
427 IWebUiEventListener* __pUserUiListener;
428 IWebUiEventListenerF* __pUserUiListenerF;
429 IWebKeypadEventListener* __pUserKeypadEventListener;
430 ITextSearchListener* __pTextSearchListener;
432 std::unique_ptr<Tizen::Ui::Controls::Keypad> __pKeypad;
434 std::unique_ptr<Tizen::Base::Collection::HashMapT< Tizen::Base::String, IJavaScriptBridge* > > __pJsBridgeList;
435 std::unique_ptr<_JsBridgeHashCodeProvider> __pJsProvider;
436 std::unique_ptr<_JsBridgeComparer> __pJsComparer;
438 std::unique_ptr<_WebDataHandler> __pWebDownloadHandler;
440 std::unique_ptr<_WebEvent> __pWebEvent;
442 std::unique_ptr<AuthenticationChallenge> __pAuthChallenge;
443 std::unique_ptr<_AuthConfirmPopup> __pAuthPopup;
445 std::unique_ptr<_UserConfirmPopup> __pUserConfirmPopup;
447 std::unique_ptr<_CertificateConfirmPopup> __pCertConfirmPopup;
449 std::unique_ptr<_SelectBox> __pSelectBox;
450 std::unique_ptr<_InputPickerPopup> __pDatePicker;
451 std::unique_ptr<_InputPickerPopup> __pColorPicker;
453 std::unique_ptr<Tizen::System::_VibratorImpl> __pVibrator;
455 Tizen::Base::Runtime::Mutex __mutex;
457 _TextSearch __textSearch;
459 Tizen::Base::Collection::ArrayList __callbackList;
461 DecisionPolicy __policy;
463 Tizen::Base::String __defaultUserAgent;
466 }}} // Tizen::Web::Controls
467 #endif // _FWEB_CTRL_INTERNAL_WEB_IMPL_H_