From 39560fc622a2acc3d8ad6ee596c6b86aa1d589f0 Mon Sep 17 00:00:00 2001 From: Jiyun Yang Date: Wed, 8 May 2019 20:24:53 +0900 Subject: [PATCH] Implement WebEngine APIs New * Suspend * Resume * ClearCookies * Get/SetCacheModel * Get/SetCookieAcceptPolicy * Get/SetUserAgent * Get/SetJavaScriptEnabled * Get/SetLoadImageAutomatically * Get/SetDefaultTextEncodingName * Get/SetDefaultFontSize * PageLoadErrorSignal Modify * EvaluateJavaScript Change-Id: Idb67d3d5644912cac4d0a1803f9ef094db97e07e Signed-off-by: Jiyun Yang --- .../adaptor-framework/web-engine-plugin.h | 179 ++++++++++++++++- dali/devel-api/adaptor-framework/web-engine.cpp | 98 +++++++++- dali/devel-api/adaptor-framework/web-engine.h | 127 +++++++++++- .../internal/web-engine/common/web-engine-impl.cpp | 217 ++++++++++++--------- dali/internal/web-engine/common/web-engine-impl.h | 105 +++++++++- 5 files changed, 617 insertions(+), 109 deletions(-) diff --git a/dali/devel-api/adaptor-framework/web-engine-plugin.h b/dali/devel-api/adaptor-framework/web-engine-plugin.h index 68cdd90..b8d6379 100644 --- a/dali/devel-api/adaptor-framework/web-engine-plugin.h +++ b/dali/devel-api/adaptor-framework/web-engine-plugin.h @@ -37,7 +37,57 @@ class WebEnginePlugin { public: - typedef Signal< void( const std::string& ) > WebEngineSignalType; + /** + * @brief WebEngine signal type related with page loading. + */ + typedef Signal< void( const std::string& ) > WebEnginePageLoadSignalType; + + /** + * @brief WebView signal type related with page loading error. + */ + typedef Signal< void( const std::string&, int ) > WebEnginePageLoadErrorSignalType; + + /** + * @brief Enumeration for cache model options. + */ + enum class CacheModel + { + /** + * @brief Use the smallest cache capacity. + */ + DOCUMENT_VIEWER, + + /** + * @brief Use the bigger cache capacity than DocumentBrowser. + */ + DOCUMENT_BROWSER, + + /** + * @brief Use the biggest cache capacity. + */ + PRIMARY_WEB_BROWSER + }; + + /** + * @brief Enumeration for the cookies accept policies. + */ + enum class CookieAcceptPolicy + { + /** + * @brief Accepts every cookie sent from any page. + */ + ALWAYS, + + /** + * @brief Rejects all the cookies. + */ + NEVER, + + /** + * @brief Accepts only cookies set by the main document that is loaded. + */ + NO_THIRD_PARTY + }; /** * @brief Constructor. @@ -105,6 +155,16 @@ public: virtual void StopLoading() = 0; /** + * @brief Suspends the operation associated with the view. + */ + virtual void Suspend() = 0; + + /** + * @brief Resumes the operation associated with the view object after calling Suspend(). + */ + virtual void Resume() = 0; + + /** * @brief Returns whether forward is possible. * * @return True if forward is possible, false otherwise @@ -132,8 +192,9 @@ public: * @brief Evaluates JavaScript code represented as a string. * * @param[in] script The JavaScript code + * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result. */ - virtual void EvaluateJavaScript( const std::string& script ) = 0; + virtual void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) = 0; /** * @brief Add a message handler into JavaScript. @@ -154,6 +215,109 @@ public: virtual void ClearCache() = 0; /** + * @brief Clears all the cookies of Web. + */ + virtual void ClearCookies() = 0; + + /** + * @brief Get cache model option. The default is DOCUMENT_VIEWER. + * + * @return The cache model option + */ + virtual CacheModel GetCacheModel() const = 0; + + /** + * @brief Set cache model option. The default is DOCUMENT_VIEWER. + * + * @param[in] cacheModel The cache model option + */ + virtual void SetCacheModel( CacheModel cacheModel ) = 0; + + /** + * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY. + * + * @return The cookie acceptance policy + */ + virtual CookieAcceptPolicy GetCookieAcceptPolicy() const = 0; + + /** + * @brief Sets the cookie acceptance policy. The default is NO_THIRD_PARTY. + * + * @param[in] policy The cookie acceptance policy + */ + virtual void SetCookieAcceptPolicy( CookieAcceptPolicy policy ) = 0; + + /** + * @brief Get user agent string. + * + * @return The string value of user agent + */ + virtual const std::string& GetUserAgent() const = 0; + + /** + * @brief Set user agent string. + * + * @param[in] userAgent The string value of user agent + */ + virtual void SetUserAgent( const std::string& userAgent ) = 0; + + /** + * @brief Returns whether JavaScript can be executable. The default is true. + * + * @return true if JavaScript executing is enabled, false otherwise + */ + virtual bool IsJavaScriptEnabled() const = 0; + + /** + * @brief Enables/disables JavaScript executing. The default is enabled. + * + * @param[in] enabled True if JavaScript executing is enabled, false otherwise + */ + virtual void EnableJavaScript( bool enabled ) = 0; + + /** + * @brief Returns whether images can be loaded automatically. The default is true. + * + * @return true if images are loaded automatically, false otherwise + */ + virtual bool AreImagesAutomaticallyLoaded() const = 0; + + /** + * @brief Enables/disables auto loading of images. The default is enabled. + * + * @param[in] automatic True if images are loaded automatically, false otherwise + */ + virtual void LoadImagesAutomatically( bool automatic ) = 0; + + /** + * @brief Gets the default text encoding name (e.g. UTF-8). + * + * @return The default text encoding name + */ + virtual const std::string& GetDefaultTextEncodingName() const = 0; + + /** + * @brief Sets the default text encoding name (e.g. UTF-8). + * + * @param[in] defaultTextEncodingName The default text encoding name + */ + virtual void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) = 0; + + /** + * @brief Returns the default font size in pixel. The default value is 16. + * + * @return The default font size + */ + virtual int GetDefaultFontSize() const = 0; + + /** + * @brief Sets the default font size in pixel. The default value is 16. + * + * @param[in] defaultFontSize A new default font size to set + */ + virtual void SetDefaultFontSize( int defaultFontSize ) = 0; + + /** * @brief Sets size of Web Page. */ virtual void SetSize( int width, int height ) = 0; @@ -173,14 +337,21 @@ public: * * @return A signal object to connect with. */ - virtual WebEngineSignalType& PageLoadStartedSignal() = 0; + virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0; /** * @brief Connects to this signal to be notified when page loading is finished. * * @return A signal object to connect with. */ - virtual WebEngineSignalType& PageLoadFinishedSignal() = 0; + virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0; + + /** + * @brief Connects to this signal to be notified when an error occurs in page loading. + * + * @return A signal object to connect with. + */ + virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0; }; diff --git a/dali/devel-api/adaptor-framework/web-engine.cpp b/dali/devel-api/adaptor-framework/web-engine.cpp index 9233f28..04a7368 100644 --- a/dali/devel-api/adaptor-framework/web-engine.cpp +++ b/dali/devel-api/adaptor-framework/web-engine.cpp @@ -103,6 +103,16 @@ void WebEngine::StopLoading() GetImplementation( *this ).StopLoading(); } +void WebEngine::Suspend() +{ + GetImplementation( *this ).Suspend(); +} + +void WebEngine::Resume() +{ + GetImplementation( *this ).Resume(); +} + bool WebEngine::CanGoForward() { return GetImplementation( *this ).CanGoForward(); @@ -123,9 +133,9 @@ void WebEngine::GoBack() GetImplementation( *this ).GoBack(); } -void WebEngine::EvaluateJavaScript( const std::string& script ) +void WebEngine::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) { - GetImplementation( *this ).EvaluateJavaScript( script ); + GetImplementation( *this ).EvaluateJavaScript( script, resultHandler ); } void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ) @@ -143,6 +153,81 @@ void WebEngine::ClearCache() return GetImplementation( *this ).ClearCache(); } +void WebEngine::ClearCookies() +{ + return GetImplementation( *this ).ClearCookies(); +} + +Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const +{ + return GetImplementation( *this ).GetCacheModel(); +} + +void WebEngine::SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ) +{ + GetImplementation( *this ).SetCacheModel( cacheModel ); +} + +Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const +{ + return GetImplementation( *this ).GetCookieAcceptPolicy(); +} + +void WebEngine::SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ) +{ + GetImplementation( *this ).SetCookieAcceptPolicy( policy ); +} + +const std::string& WebEngine::GetUserAgent() const +{ + return GetImplementation( *this ).GetUserAgent(); +} + +void WebEngine::SetUserAgent( const std::string& userAgent ) +{ + GetImplementation( *this ).SetUserAgent( userAgent ); +} + +bool WebEngine::IsJavaScriptEnabled() const +{ + return GetImplementation( *this ).IsJavaScriptEnabled(); +} + +void WebEngine::EnableJavaScript( bool enabled ) +{ + GetImplementation( *this ).EnableJavaScript( enabled ); +} + +bool WebEngine::AreImagesAutomaticallyLoaded() const +{ + return GetImplementation( *this ).AreImagesAutomaticallyLoaded(); +} + +void WebEngine::LoadImagesAutomatically( bool automatic ) +{ + GetImplementation( *this ).LoadImagesAutomatically( automatic ); +} + +const std::string& WebEngine::GetDefaultTextEncodingName() const +{ + return GetImplementation( *this ).GetDefaultTextEncodingName(); +} + +void WebEngine::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) +{ + GetImplementation( *this ).SetDefaultTextEncodingName( defaultTextEncodingName ); +} + +int WebEngine::GetDefaultFontSize() const +{ + return GetImplementation( *this ).GetDefaultFontSize(); +} + +void WebEngine::SetDefaultFontSize( int defaultFontSize ) +{ + GetImplementation( *this ).SetDefaultFontSize( defaultFontSize ); +} + void WebEngine::SetSize( int width, int height ) { return GetImplementation( *this ).SetSize( width, height ); @@ -158,15 +243,20 @@ bool WebEngine::SendKeyEvent( const KeyEvent& event ) return GetImplementation( *this ).SendKeyEvent( event ); } -Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadStartedSignal() +Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal() { return GetImplementation( *this ).PageLoadStartedSignal(); } -Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadFinishedSignal() +Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal() { return GetImplementation( *this ).PageLoadFinishedSignal(); } +Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal() +{ + return GetImplementation( *this ).PageLoadErrorSignal(); +} + } // namespace Dali; diff --git a/dali/devel-api/adaptor-framework/web-engine.h b/dali/devel-api/adaptor-framework/web-engine.h index ca0e686..e9b604e 100644 --- a/dali/devel-api/adaptor-framework/web-engine.h +++ b/dali/devel-api/adaptor-framework/web-engine.h @@ -139,6 +139,16 @@ public: void StopLoading(); /** + * @brief Suspends the operation associated with the view. + */ + void Suspend(); + + /** + * @brief Resumes the operation associated with the view object after calling Suspend(). + */ + void Resume(); + + /** * @brief Returns whether forward is possible. * * @return True if forward is possible, false otherwise @@ -166,8 +176,9 @@ public: * @brief Evaluates JavaScript code represented as a string. * * @param[in] script The JavaScript code + * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result. */ - void EvaluateJavaScript( const std::string& script ); + void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ); /** * @brief Add a message handler into JavaScript. @@ -188,6 +199,109 @@ public: void ClearCache(); /** + * @brief Clears all the cookies of Web. + */ + void ClearCookies(); + + /** + * @brief Get cache model option. The default is DOCUMENT_VIEWER. + * + * @return The cache model option + */ + Dali::WebEnginePlugin::CacheModel GetCacheModel() const; + + /** + * @brief Set cache model option. The default is DOCUMENT_VIEWER. + * + * @param[in] cacheModel The cache model option + */ + void SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ); + + /** + * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY. + * + * @return The cookie acceptance policy + */ + Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const; + + /** + * @brief Sets the cookie acceptance policy. The default is NO_THIRD_PARTY. + * + * @param[in] policy The cookie acceptance policy + */ + void SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ); + + /** + * @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 Returns whether JavaScript can be executable. The default is true. + * + * @return true if JavaScript executing is enabled, false otherwise + */ + bool IsJavaScriptEnabled() const; + + /** + * @brief Enables/disables JavaScript executing. The default is enabled. + * + * @param[in] enabled True if JavaScript executing is enabled, false otherwise + */ + void EnableJavaScript( bool enabled ); + + /** + * @brief Returns whether JavaScript can be executable. The default is true. + * + * @return true if images are loaded automatically, false otherwise + */ + bool AreImagesAutomaticallyLoaded() const; + + /** + * @brief Enables/disables auto loading of images. The default is enabled. + * + * @param[in] automatic True if images are loaded automatically, false otherwise + */ + void LoadImagesAutomatically( bool automatic ); + + /** + * @brief Gets the default text encoding name. + * + * @return The default text encoding name + */ + const std::string& GetDefaultTextEncodingName() const; + + /** + * @brief Sets the default text encoding name. + * + * @param[in] defaultTextEncodingName The default text encoding name + */ + void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ); + + /** + * @brief Returns the default font size in pixel. The default value is 16. + * + * @return The default font size + */ + int GetDefaultFontSize() const; + + /** + * @brief Sets the default font size in pixel. The default value is 16. + * + * @param[in] defaultFontSize A new default font size to set + */ + void SetDefaultFontSize( int defaultFontSize ); + + /** * @brief Sets the size of Web Pages. */ void SetSize( int width, int height ); @@ -207,14 +321,21 @@ public: * * @return A signal object to connect with. */ - Dali::WebEnginePlugin::WebEngineSignalType& PageLoadStartedSignal(); + Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal(); /** * @brief Connects to this signal to be notified when page loading is finished. * * @return A signal object to connect with. */ - Dali::WebEnginePlugin::WebEngineSignalType& PageLoadFinishedSignal(); + Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal(); + + /** + * @brief Connects to this signal to be notified when an error occurs in page loading. + * + * @return A signal object to connect with. + */ + Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal(); private: // Not intended for application developers diff --git a/dali/internal/web-engine/common/web-engine-impl.cpp b/dali/internal/web-engine/common/web-engine-impl.cpp index 526926a..a8c40b5 100644 --- a/dali/internal/web-engine/common/web-engine-impl.cpp +++ b/dali/internal/web-engine/common/web-engine-impl.cpp @@ -67,17 +67,15 @@ Dali::TypeRegistration type( typeid( Dali::WebEngine ), typeid( Dali::BaseHandle WebEnginePtr WebEngine::New() { - WebEnginePtr ptr; - WebEngine* engine = new WebEngine(); + WebEngine* instance = new WebEngine(); - if ( !engine->Initialize() ) + if( !instance->Initialize() ) { - delete engine; - engine = nullptr; + delete instance; + return nullptr; } - ptr = engine; - return ptr; + return instance; } WebEngine::WebEngine() @@ -104,15 +102,15 @@ WebEngine::~WebEngine() bool WebEngine::InitializePluginHandle() { - if ( pluginName.length() == 0 ) + if( pluginName.length() == 0 ) { // pluginName is not initialized yet. const char* name = EnvironmentVariable::GetEnvironmentVariable( DALI_ENV_WEB_ENGINE_NAME ); - if ( name ) + if( name ) { pluginName = MakePluginName( name ); mHandle = dlopen( pluginName.c_str(), RTLD_LAZY ); - if ( mHandle ) + if( mHandle ) { return true; } @@ -121,7 +119,7 @@ bool WebEngine::InitializePluginHandle() } mHandle = dlopen( pluginName.c_str(), RTLD_LAZY ); - if ( !mHandle ) + if( !mHandle ) { DALI_LOG_ERROR( "Can't load %s : %s\n", pluginName.c_str(), dlerror() ); return false; @@ -134,7 +132,7 @@ bool WebEngine::Initialize() { char* error = NULL; - if ( !InitializePluginHandle() ) + if( !InitializePluginHandle() ) { return false; } @@ -146,20 +144,19 @@ bool WebEngine::Initialize() return false; } - mPlugin = mCreateWebEnginePtr(); + mDestroyWebEnginePtr = reinterpret_cast< DestroyWebEngineFunction >( dlsym( mHandle, "DestroyWebEnginePlugin" ) ); - if( mPlugin == NULL ) + if( mDestroyWebEnginePtr == NULL ) { - DALI_LOG_ERROR( "Can't create the WebEnginePlugin object\n" ); + DALI_LOG_ERROR( "Can't load symbol DestroyWebEnginePlugin(), error: %s\n", error ); return false; } - mDestroyWebEnginePtr = reinterpret_cast< DestroyWebEngineFunction >( dlsym( mHandle, "DestroyWebEnginePlugin" ) ); + mPlugin = mCreateWebEnginePtr(); - if( mDestroyWebEnginePtr == NULL ) + if( mPlugin == NULL ) { - - DALI_LOG_ERROR( "Can't load symbol DestroyWebEnginePlugin(), error: %s\n", error ); + DALI_LOG_ERROR( "Can't create the WebEnginePlugin object\n" ); return false; } @@ -168,18 +165,12 @@ bool WebEngine::Initialize() void WebEngine::Create( int width, int height, const std::string& locale, const std::string& timezoneId ) { - if( mPlugin != NULL ) - { - mPlugin->Create( width, height, locale, timezoneId ); - } + mPlugin->Create( width, height, locale, timezoneId ); } void WebEngine::Destroy() { - if( mPlugin != NULL ) - { - mPlugin->Destroy(); - } + mPlugin->Destroy(); } Dali::NativeImageInterfacePtr WebEngine::GetNativeImageSource() @@ -189,138 +180,184 @@ Dali::NativeImageInterfacePtr WebEngine::GetNativeImageSource() void WebEngine::LoadUrl( const std::string& url ) { - if( mPlugin != NULL ) - { - mPlugin->LoadUrl( url ); - } + mPlugin->LoadUrl( url ); } const std::string& WebEngine::GetUrl() { - static std::string emptyUrl; - return mPlugin ? mPlugin->GetUrl() : emptyUrl; + return mPlugin->GetUrl(); } void WebEngine::LoadHTMLString( const std::string& htmlString ) { - if( mPlugin != NULL ) - { - mPlugin->LoadHTMLString( htmlString ); - } + mPlugin->LoadHTMLString( htmlString ); } void WebEngine::Reload() { - if( mPlugin != NULL ) - { - mPlugin->Reload(); - } + mPlugin->Reload(); } void WebEngine::StopLoading() { - if( mPlugin != NULL ) - { - mPlugin->StopLoading(); - } + mPlugin->StopLoading(); +} + +void WebEngine::Suspend() +{ + mPlugin->Suspend(); +} + +void WebEngine::Resume() +{ + mPlugin->Resume(); } bool WebEngine::CanGoForward() { - return mPlugin ? mPlugin->CanGoForward() : false; + return mPlugin->CanGoForward(); } void WebEngine::GoForward() { - if( mPlugin != NULL ) - { - mPlugin->GoForward(); - } + mPlugin->GoForward(); } bool WebEngine::CanGoBack() { - return mPlugin ? mPlugin->CanGoBack() : false; + return mPlugin->CanGoBack(); } void WebEngine::GoBack() { - if( mPlugin != NULL ) - { - mPlugin->GoBack(); - } + mPlugin->GoBack(); } -void WebEngine::EvaluateJavaScript( const std::string& script ) +void WebEngine::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) { - if( mPlugin != NULL ) - { - mPlugin->EvaluateJavaScript( script ); - } + mPlugin->EvaluateJavaScript( script, resultHandler ); } void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler ) { - if( mPlugin != NULL ) - { - mPlugin->AddJavaScriptMessageHandler( exposedObjectName, handler ); - } + mPlugin->AddJavaScriptMessageHandler( exposedObjectName, handler ); } void WebEngine::ClearHistory() { - if( mPlugin != NULL ) - { - mPlugin->ClearHistory(); - } + mPlugin->ClearHistory(); } void WebEngine::ClearCache() { - if( mPlugin != NULL ) - { - mPlugin->ClearCache(); - } + mPlugin->ClearCache(); +} + +void WebEngine::ClearCookies() +{ + mPlugin->ClearCookies(); +} + +Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const +{ + return mPlugin->GetCacheModel(); +} + +void WebEngine::SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ) +{ + mPlugin->SetCacheModel( cacheModel ); +} + +Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const +{ + return mPlugin->GetCookieAcceptPolicy(); +} + +void WebEngine::SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ) +{ + mPlugin->SetCookieAcceptPolicy( policy ); +} + +const std::string& WebEngine::GetUserAgent() const +{ + return mPlugin->GetUserAgent(); +} + +void WebEngine::SetUserAgent( const std::string& userAgent ) +{ + mPlugin->SetUserAgent( userAgent ); +} + +bool WebEngine::IsJavaScriptEnabled() const +{ + return mPlugin->IsJavaScriptEnabled(); +} + +void WebEngine::EnableJavaScript( bool enabled ) +{ + mPlugin->EnableJavaScript( enabled ); +} + +bool WebEngine::AreImagesAutomaticallyLoaded() const +{ + return mPlugin->AreImagesAutomaticallyLoaded(); +} + +void WebEngine::LoadImagesAutomatically( bool automatic ) +{ + mPlugin->LoadImagesAutomatically( automatic ); +} + +const std::string& WebEngine::GetDefaultTextEncodingName() const +{ + return mPlugin->GetDefaultTextEncodingName(); +} + +void WebEngine::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) +{ + mPlugin->SetDefaultTextEncodingName( defaultTextEncodingName ); +} + +int WebEngine::GetDefaultFontSize() const +{ + return mPlugin->GetDefaultFontSize(); +} + +void WebEngine::SetDefaultFontSize( int defaultFontSize ) +{ + mPlugin->SetDefaultFontSize( defaultFontSize ); } void WebEngine::SetSize( int width, int height ) { - if( mPlugin != NULL ) - { - mPlugin->SetSize( width, height ); - } + mPlugin->SetSize( width, height ); } bool WebEngine::SendTouchEvent( const Dali::TouchData& touch ) { - if( mPlugin != NULL ) - { - return mPlugin->SendTouchEvent( touch ); - } - - return false; + return mPlugin->SendTouchEvent( touch ); } bool WebEngine::SendKeyEvent( const Dali::KeyEvent& event ) { - if( mPlugin != NULL ) - { - return mPlugin->SendKeyEvent( event ); - } - - return false; + return mPlugin->SendKeyEvent( event ); } -Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadStartedSignal() +Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal() { return mPlugin->PageLoadStartedSignal(); } -Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadFinishedSignal() +Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal() { return mPlugin->PageLoadFinishedSignal(); } +Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal() +{ + return mPlugin->PageLoadErrorSignal(); +} + } // namespace Adaptor; } // namespace Internal; } // namespace Dali; diff --git a/dali/internal/web-engine/common/web-engine-impl.h b/dali/internal/web-engine/common/web-engine-impl.h index 6f0a933..bf64b23 100644 --- a/dali/internal/web-engine/common/web-engine-impl.h +++ b/dali/internal/web-engine/common/web-engine-impl.h @@ -93,6 +93,16 @@ public: void StopLoading(); /** + * @copydoc Dali::WebEngine::Suspend() + */ + void Suspend(); + + /** + * @copydoc Dali::WebEngine::Resume() + */ + void Resume(); + + /** * @copydoc Dali::WebEngine::CanGoForward() */ bool CanGoForward(); @@ -115,7 +125,7 @@ public: /** * @copydoc Dali::WebEngine::EvaluateJavaScript() */ - void EvaluateJavaScript( const std::string& script ); + void EvaluateJavaScript( const std::string& script, std::function< void(const std::string&) > resultHandler ); /** * @copydoc Dali::WebEngine::AddJavaScriptMessageHandler() @@ -133,6 +143,81 @@ public: void ClearCache(); /** + * @copydoc Dali::WebEngine::ClearCookies() + */ + void ClearCookies(); + + /** + * @copydoc Dali::WebEngine::GetCacheModel() + */ + Dali::WebEnginePlugin::CacheModel GetCacheModel() const; + + /** + * @copydoc Dali::WebEngine::SetCacheModel() + */ + void SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ); + + /** + * @copydoc Dali::WebEngine::GetCookieAcceptPolicy() + */ + Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const; + + /** + * @copydoc Dali::WebEngine::SetCookieAcceptPolicy() + */ + void SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ); + + /** + * @copydoc Dali::WebEngine::GetUserAgent() + */ + const std::string& GetUserAgent() const; + + /** + * @copydoc Dali::WebEngine::SetUserAgent() + */ + void SetUserAgent( const std::string& userAgent ); + + /** + * @copydoc Dali::WebEngine::IsJavaScriptEnabled() + */ + bool IsJavaScriptEnabled() const; + + /** + * @copydoc Dali::WebEngine::EnableJavaScript() + */ + void EnableJavaScript( bool enabled ); + + /** + * @copydoc Dali::WebEngine::AreImagesAutomaticallyLoaded() + */ + bool AreImagesAutomaticallyLoaded() const; + + /** + * @copydoc Dali::WebEngine::LoadImagesAutomatically() + */ + void LoadImagesAutomatically( bool automatic ); + + /** + * @copydoc Dali::WebEngine::GetDefaultTextEncodingName() + */ + const std::string& GetDefaultTextEncodingName() const; + + /** + * @copydoc Dali::WebEngine::SetDefaultTextEncodingName() + */ + void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ); + + /** + * @copydoc Dali::WebEngine::GetDefaultFontSize() + */ + int GetDefaultFontSize() const; + + /** + * @copydoc Dali::WebEngine::SetDefaultFontSize() + */ + void SetDefaultFontSize( int defaultFontSize ); + + /** * @copydoc Dali::WebEngine::SetSize() */ void SetSize( int width, int height ); @@ -150,12 +235,17 @@ public: /** * @copydoc Dali::WebEngine::PageLoadStartedSignal() */ - Dali::WebEnginePlugin::WebEngineSignalType& PageLoadStartedSignal(); + Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal(); /** * @copydoc Dali::WebEngine::PageLoadFinishedSignal() */ - Dali::WebEnginePlugin::WebEngineSignalType& PageLoadFinishedSignal(); + Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal(); + + /** + * @copydoc Dali::WebEngine::PageLoadErrorSignal() + */ + Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal(); private: @@ -191,14 +281,13 @@ private: private: - Dali::WebEnginePlugin* mPlugin; ///< WebEnginePlugin instance - void* mHandle; ///< Handle for the loaded library - typedef Dali::WebEnginePlugin* (*CreateWebEngineFunction)(); typedef void (*DestroyWebEngineFunction)( Dali::WebEnginePlugin* plugin ); - CreateWebEngineFunction mCreateWebEnginePtr; - DestroyWebEngineFunction mDestroyWebEnginePtr; + Dali::WebEnginePlugin* mPlugin; ///< WebEnginePlugin instance + void* mHandle; ///< Handle for the loaded library + CreateWebEngineFunction mCreateWebEnginePtr; ///< Function to create plugin instance + DestroyWebEngineFunction mDestroyWebEnginePtr; ///< Function to destroy plugin instance }; } // namespace Adaptor -- 2.7.4