#define DALI_TOOLKIT_INTERNAL_WEB_VIEW_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
*/
// EXTERNAL INCLUDES
+#include <memory>
#include <dali/devel-api/adaptor-framework/web-engine.h>
#include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/object/property-notification.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
namespace Dali
{
{
class KeyEvent;
-class TouchData;
+class TouchEvent;
+class WebBackForwardList;
+class WebContext;
+class WebCookieManager;
+class WebSettings;
class WebView;
namespace Internal
WebView( const std::string& locale, const std::string& timezoneId );
+ WebView( int argc, char** argv );
+
virtual ~WebView();
public:
static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId );
/**
- * @copydoc Dali::Toolkit::WebView::LoadUrl()
+ * @brief Get settings of WebEngine.
*/
- void LoadUrl( const std::string& url );
+ 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;
/**
- * @copydoc Dali::Toolkit::WebView::GetUrl()
+ * @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 favicon
+ */
+ Dali::Toolkit::ImageView GetFavicon() const;
+
+ /**
+ * @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 );
+ void EvaluateJavaScript( const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler );
/**
- * @copydoc Dali::WebEngine::AddJavaScriptInterface()
+ * @copydoc Dali::Toolkit::WebView::AddJavaScriptMessageHandler()
*/
- void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback );
+ void AddJavaScriptMessageHandler( const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler );
/**
- * @copydoc Dali::WebEngine::RemoveJavascriptInterface()
+ * @brief Clears all tiles resources of Web.
*/
- void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName );
+ void ClearAllTilesResources();
/**
- * @copydoc Dali::WebEngine::ClearHistory()
+ * @copydoc Dali::Toolkit::WebView::ClearHistory()
*/
void ClearHistory();
/**
- * @copydoc Dali::WebEngine::ClearCache()
+ * @copydoc Dali::Toolkit::WebView::SetTtsFocus()
+ */
+ void SetTtsFocus(bool focused);
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::RegisterPageLoadStartedCallback()
+ */
+ void RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback);
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::RegisterPageLoadFinishedCallback()
+ */
+ void RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback);
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::RegisterPageLoadErrorCallback()
+ */
+ void RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback);
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::RegisterScrollEdgeReachedCallback()
*/
- void ClearCache();
+ void RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback);
/**
- * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
+ * @copydoc Dali::Toolkit::WebView::RegisterNavigationPolicyDecidedCallback()
*/
- Dali::Toolkit::WebView::WebViewSignalType& PageLoadStartedSignal();
+ void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
/**
- * @copydoc Dali::Toolkit::WebView::PageLoadFinishedSignal()
+ * @copydoc Dali::Toolkit::WebView::GetPlainTextAsynchronously()
*/
- Dali::Toolkit::WebView::WebViewSignalType& PageLoadFinishedSignal();
+ void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback);
public: // Properties
*/
static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
- /**
- * Connects a callback function with the object's signals.
- * @param[in] object The object providing the signal.
- * @param[in] tracker Used to disconnect the signal.
- * @param[in] signalName The signal to connect to.
- * @param[in] functor A newly allocated FunctorDelegate.
- * @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 );
-
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.
* @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;
+
+ /**
+ * @copydoc Toolkit::Control::OnKeyInputFocusGained()
+ */
+ void OnKeyInputFocusGained() override;
+
+ /**
+ * @copydoc Toolkit::Control::OnKeyInputFocusLost()
+ */
+ void OnKeyInputFocusLost() override;
+
+ /**
+ * @copydoc Toolkit::Control::OnSceneConnection()
+ */
+ void OnSceneConnection( int depth ) override;
private:
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 );
+
+ /**
+ * @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
+ */
+ void GetScrollPosition( int& x, int& y ) const;
+
+ /**
+ * @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
+ */
+ void GetScrollSize( int& width, int& height ) 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
+ */
+ void GetContentSize( int& width, int& height ) 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;
+
+ /**
+ * @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 );
- void OnPageLoadFinished( const std::string& url );
+ /**
+ * @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 );
private:
- std::string mUrl;
- Dali::Toolkit::Visual::Base mVisual;
- Dali::Size mWebViewSize;
- Dali::WebEngine mWebEngine;
- Dali::Toolkit::WebView::WebViewSignalType mPageLoadStartedSignal;
- Dali::Toolkit::WebView::WebViewSignalType mPageLoadFinishedSignal;
+ std::string mUrl;
+ Dali::Toolkit::Visual::Base mVisual;
+ Dali::Size mWebViewSize;
+ Dali::WebEngine mWebEngine;
+
+ std::unique_ptr<Dali::Toolkit::WebContext> mWebContext;
+ std::unique_ptr<Dali::Toolkit::WebCookieManager> mWebCookieManager;
+ std::unique_ptr<Dali::Toolkit::WebSettings> mWebSettings;
+ std::unique_ptr<Dali::Toolkit::WebBackForwardList> mWebBackForwardList;
+
+ Dali::PropertyNotification mPositionUpdateNotification;
+ Dali::PropertyNotification mSizeUpdateNotification;
+ Dali::PropertyNotification mScaleUpdateNotification;
+ bool mVideoHoleEnabled;
+ Dali::Rect< int > mWebViewArea;
};
} // namespace Internal