X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fweb-view%2Fweb-view-impl.h;h=065dc45b97cda0d8ff90e6ad81e926c13253de0c;hb=c08d22543ee991b6c70168bd4267294fe965fb51;hp=54a679ff142df43e581ddb12833912e33fc61449;hpb=6f14d95105863d879b5888ad4eb964db9b70f9ff;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.h b/dali-toolkit/internal/controls/web-view/web-view-impl.h index 54a679f..065dc45 100644 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_WEB_VIEW_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,37 +21,41 @@ // EXTERNAL INCLUDES #include #include +#include +#include // INTERNAL INCLUDES +#include #include #include -#include +#include namespace Dali { - namespace Toolkit { - class KeyEvent; -class TouchData; +class TouchEvent; +class WebBackForwardList; +class WebContext; +class WebCookieManager; +class WebSettings; class WebView; namespace Internal { - class WebView : public Control { protected: - WebView(); - WebView( const std::string& locale, const std::string& timezoneId ); + WebView(const std::string& locale, const std::string& timezoneId); + + WebView(int argc, char** argv); virtual ~WebView(); public: - /** * @copydoc Dali::Toolkit::WebView::New() */ @@ -60,98 +64,184 @@ public: /** * @copydoc Dali::Toolkit::WebView::New( const std::string&, const std::string& ) */ - static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId ); + static Toolkit::WebView New(const std::string& locale, const std::string& timezoneId); /** - * @copydoc Dali::Toolkit::WebView::LoadUrl() + * @brief Get settings of WebEngine. + */ + Dali::Toolkit::WebSettings* GetSettings() const; + + /** + * @brief Get context of WebEngine. + */ + Dali::Toolkit::WebContext* GetContext() const; + + /** + * @brief Get cookie manager of WebEngine. + */ + Dali::Toolkit::WebCookieManager* GetCookieManager() const; + + /** + * @brief Get WebBackForwardList of WebEngine. + */ + Dali::Toolkit::WebBackForwardList* GetBackForwardList() const; + + /** + * @copydoc Dali::Toolkit::WebView::New( int, char** ) + */ + static Toolkit::WebView New(int argc, char** argv); + + /** + * @brief Get Favicon of web page. + * + * @return Handle to a fav icon */ - void LoadUrl( const std::string& url ); + Dali::Toolkit::ImageView& GetFavicon(); /** - * @copydoc Dali::Toolkit::WebView::GetUrl() + * @copydoc Dali::Toolkit::WebView::LoadUrl() */ - const std::string& GetUrl(); + void LoadUrl(const std::string& url); /** * @copydoc Dali::WebEngine::LoadHTMLString() */ - void LoadHTMLString( const std::string& htmlString ); + void LoadHtmlString(const std::string& htmlString); /** - * @copydoc Dali::WebEngine::Reload() + * @copydoc Dali::Toolkit::WebView::Reload() */ void Reload(); /** - * @copydoc Dali::WebEngine::StopLoading() + * @copydoc Dali::Toolkit::WebView::StopLoading() */ void StopLoading(); /** - * @copydoc Dali::WebEngine::CanGoForward() + * @copydoc Dali::Toolkit::WebView::StopLoading() + */ + void Suspend(); + + /** + * @copydoc Dali::Toolkit::WebView::Resume() + */ + void Resume(); + + /** + * @copydoc Dali::Toolkit::WebView::ScrollBy() + */ + void ScrollBy(int deltaX, int deltaY); + + /** + * @copydoc Dali::Toolkit::WebView::CanGoForward() */ bool CanGoForward(); /** - * @copydoc Dali::WebEngine::GoForward() + * @copydoc Dali::Toolkit::WebView::GoForward() */ void GoForward(); /** - * @copydoc Dali::WebEngine::CanGoBack() + * @copydoc Dali::Toolkit::WebView::CanGoBack() */ bool CanGoBack(); /** - * @copydoc Dali::WebEngine::GoBack() + * @copydoc Dali::Toolkit::WebView::GoBack() */ void GoBack(); /** - * @copydoc Dali::WebEngine::EvaluateJavaScript() + * @copydoc Dali::Toolkit::WebView::EvaluateJavaScript() + */ + void EvaluateJavaScript(const std::string& script, std::function resultHandler); + + /** + * @copydoc Dali::Toolkit::WebView::AddJavaScriptMessageHandler() + */ + void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler); + + /** + * @copydoc Dali::Toolkit::WebView::RegisterJavaScriptAlertCallback() + */ + void RegisterJavaScriptAlertCallback( Dali::WebEnginePlugin::JavaScriptAlertCallback callback ); + + /** + * @copydoc Dali::Toolkit::WebView::JavaScriptAlertReply() */ - void EvaluateJavaScript( const std::string& script ); + void JavaScriptAlertReply(); /** - * @copydoc Dali::WebEngine::AddJavaScriptInterface() + * @copydoc Dali::Toolkit::WebView::RegisterJavaScriptConfirmCallback() */ - void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback ); + void RegisterJavaScriptConfirmCallback( Dali::WebEnginePlugin::JavaScriptConfirmCallback callback ); /** - * @copydoc Dali::WebEngine::RemoveJavascriptInterface() + * @copydoc Dali::Toolkit::WebView::JavaScriptConfirmReply() */ - void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName ); + void JavaScriptConfirmReply( bool confirmed ); /** - * @copydoc Dali::WebEngine::ClearHistory() + * @copydoc Dali::Toolkit::WebView::RegisterJavaScriptPromptCallback() + */ + void RegisterJavaScriptPromptCallback( Dali::WebEnginePlugin::JavaScriptPromptCallback callback); + + /** + * @copydoc Dali::Toolkit::WebView::JavaScriptPromptReply() + */ + void JavaScriptPromptReply( const std::string& result ); + + /** + * @copydoc Dali::Toolkit::WebView::ClearHistory() */ void ClearHistory(); /** - * @copydoc Dali::WebEngine::ClearCache() + * @brief Clears all tiles resources of Web. */ - void ClearCache(); + void ClearAllTilesResources(); /** * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal() */ - Dali::Toolkit::WebView::WebViewSignalType& PageLoadStartedSignal(); + Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadStartedSignal(); + + /** + * @copydoc Dali::Toolkit::WebView::PageLoadInProgressSignal() + */ + Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadInProgressSignal(); /** * @copydoc Dali::Toolkit::WebView::PageLoadFinishedSignal() */ - Dali::Toolkit::WebView::WebViewSignalType& PageLoadFinishedSignal(); + Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadFinishedSignal(); -public: // Properties + /** + * @copydoc Dali::Toolkit::WebView::PageLoadErrorSignal() + */ + Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& PageLoadErrorSignal(); /** + * @copydoc Dali::Toolkit::WebView::ScrollEdgeReachedSignal() + */ + Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal(); + + /** + * @copydoc Dali::Toolkit::WebView::UrlChangedSignal() + */ + Dali::Toolkit::WebView::WebViewUrlChangedSignalType& UrlChangedSignal(); + +public: // Properties + /** * @brief Called when a property of an object of this type is set. * * @param[in] object The object whose property is set. * @param[in] index The property index. * @param[in] value The new property value. */ - static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value ); + static void SetProperty(Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value); /** * @brief Called to retrieve a property of an object of this type. @@ -160,7 +250,7 @@ public: // Properties * @param[in] index The property index. * @return The current value of the property. */ - static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex ); + static Dali::Property::Value GetProperty(Dali::BaseObject* object, Dali::Property::Index propertyIndex); /** * Connects a callback function with the object's signals. @@ -171,24 +261,18 @@ public: // Properties * @return True if the signal was connected. * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c */ - static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); + static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor); private: // From Control - /** * @copydoc Toolkit::Control::OnInitialize() */ - virtual void OnInitialize(); + void OnInitialize() override; /** * @copydoc Toolkit::Control::GetNaturalSize */ - virtual Vector3 GetNaturalSize(); - - /** - * @copydoc Toolkit::Control::OnRelayout() - */ - virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); + Vector3 GetNaturalSize() override; /** * Signal occurs when the Web View has been touched. @@ -196,48 +280,176 @@ private: // From Control * @param[in] touch The Touch Data. * @return Whether to consume event or not. */ - bool OnTouchEvent( Actor actor, const Dali::TouchData& touch ); + bool OnTouchEvent(Actor actor, const Dali::TouchEvent& touch); /** * @copydoc Toolkit::Control::OnKeyEvent() */ - virtual bool OnKeyEvent( const Dali::KeyEvent& event ); + bool OnKeyEvent(const Dali::KeyEvent& event) override; -private: + /** + * @copydoc Toolkit::Control::OnKeyInputFocusGained() + */ + void OnKeyInputFocusGained() override; + + /** + * @copydoc Toolkit::Control::OnKeyInputFocusLost() + */ + void OnKeyInputFocusLost() override; + + /** + * @copydoc Toolkit::Control::OnSceneConnection() + */ + void OnSceneConnection(int depth) override; +private: // Undefined - WebView( const WebView& webView ); + WebView(const WebView& webView); - WebView& operator=( const WebView& webView ); + WebView& operator=(const WebView& webView); - void OnPageLoadStarted( const std::string& url ); + /** + * @brief Sets an absolute scroll of the given view. + * @param[in] x The coordinate x of scroll + * @param[in] y The coordinate y of scroll + */ + void SetScrollPosition(int x, int y); - void OnPageLoadFinished( const std::string& url ); + /** + * @brief Gets the current scroll position of the given view. + * @param[out] x The coordinate x of scroll + * @param[out] y The coordinate y of scroll + */ + Dali::Vector2 GetScrollPosition() const; -private: + /** + * @brief Gets the possible scroll size of the given view. + * @param[out] width The width of scroll size + * @param[out] height The height of scroll size + */ + Dali::Vector2 GetScrollSize() const; + + /** + * @brief Gets the last known content's size. + * @param[out] width The width of content's size + * @param[out] height The height of content's size + */ + Dali::Vector2 GetContentSize() const; + + /** + * @brief Returns the title of the Web. + * + * @return The title of web page + */ + std::string GetTitle() const; + + /** + * @brief Get user agent string. + * @return The string value of user agent + */ + const std::string& GetUserAgent() const; - std::string mUrl; - Dali::Toolkit::Visual::Base mVisual; - Dali::Size mWebViewSize; - Dali::WebEngine mWebEngine; - Dali::Toolkit::WebView::WebViewSignalType mPageLoadStartedSignal; - Dali::Toolkit::WebView::WebViewSignalType mPageLoadFinishedSignal; + /** + * @brief Set user agent string. + * @param[in] userAgent The string value of user agent + */ + void SetUserAgent(const std::string& userAgent); + + /** + * @brief Updates display area of web view. + * @param[in] source The soource triggers Notification. + */ + void UpdateDisplayArea(Dali::PropertyNotification& source); + + /** + * @brief Enable/Disable video hole for video playing. + * @param[in] enabled True if video hole is enabled, false otherwise. + */ + void EnableVideoHole(bool enabled); + + /** + * @brief Enable blend mode. + * @param[in] blendEnabled True if turn on blend mode, false otherwise. + */ + void EnableBlendMode(bool blendEnabled); + + /** + * @brief Callback function to be called when page load started. + * @param[in] url The url currently being loaded + */ + void OnPageLoadStarted(const std::string& url); + + /** + * @brief Callback function to be called when page is loading in progress. + * @param[in] url The url currently being loaded + */ + void OnPageLoadInProgress( const std::string& url ); + + /** + * @brief Callback function to be called when page load finished. + * @param[in] url The url currently being loaded + */ + void OnPageLoadFinished(const std::string& url); + + /** + * @brief Callback function to be called when there is an error in page loading. + * @param[in] url The url currently being loaded + * @param[in] errorCode The error code + */ + void OnPageLoadError(const std::string& url, int errorCode); + + /** + * @brief Callback function to be called when scroll edge is reached. + * @param[in] e The scroll edge reached. + */ + void OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge); + + /** + * @brief Callback function to be called when url is changed. + * @param[in] url The url currently being loaded + */ + void OnUrlChanged( const std::string& url ); + +private: + std::string mUrl; + Dali::Toolkit::Visual::Base mVisual; + Dali::Size mWebViewSize; + Dali::WebEngine mWebEngine; + + Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadStartedSignal; + Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadInProgressSignal; + Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadFinishedSignal; + Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal; + Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType mScrollEdgeReachedSignal; + + std::unique_ptr mWebContext; + std::unique_ptr mWebCookieManager; + std::unique_ptr mWebSettings; + std::unique_ptr mWebBackForwardList; + Dali::Toolkit::ImageView mFaviconView; + + Dali::PropertyNotification mPositionUpdateNotification; + Dali::PropertyNotification mSizeUpdateNotification; + Dali::PropertyNotification mScaleUpdateNotification; + bool mVideoHoleEnabled; + Dali::Rect< int > mWebViewArea; + Dali::Toolkit::WebView::WebViewUrlChangedSignalType mUrlChangedSignal; }; } // namespace Internal -inline Toolkit::Internal::WebView& GetImpl( Toolkit::WebView& handle ) +inline Toolkit::Internal::WebView& GetImpl(Toolkit::WebView& handle) { - DALI_ASSERT_ALWAYS( handle ); + DALI_ASSERT_ALWAYS(handle); Dali::RefObject& impl = handle.GetImplementation(); - return static_cast< Toolkit::Internal::WebView& >( impl ); + return static_cast(impl); } -inline const Toolkit::Internal::WebView& GetImpl( const Toolkit::WebView& handle ) +inline const Toolkit::Internal::WebView& GetImpl(const Toolkit::WebView& handle) { - DALI_ASSERT_ALWAYS( handle ); + DALI_ASSERT_ALWAYS(handle); const Dali::RefObject& impl = handle.GetImplementation(); - return static_cast< const Toolkit::Internal::WebView& >( impl ); + return static_cast(impl); } } // namespace Toolkit