#include "toolkit-timer.h"
#include <dali/devel-api/adaptor-framework/web-engine.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+#include <dali/devel-api/adaptor-framework/web-engine-context.h>
+#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
#include <dali/public-api/object/any.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
}
}
+class MockWebEngineContext : public Dali::WebEngineContext
+{
+public:
+ MockWebEngineContext()
+ : mockModel( Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER )
+ {
+ }
+
+ Dali::WebEngineContext::CacheModel GetCacheModel() const override
+ {
+ return mockModel;
+ }
+
+ void SetCacheModel( Dali::WebEngineContext::CacheModel cacheModel ) override
+ {
+ mockModel = cacheModel;
+ }
+
+ void SetProxyUri( const std::string& uri ) override
+ {
+ }
+
+ void SetDefaultProxyAuth( const std::string& username, const std::string& password ) override
+ {
+ }
+
+ void SetCertificateFilePath( const std::string& certificatePath ) override
+ {
+ }
+
+ void DeleteWebDatabase() override
+ {
+ }
+
+ void DeleteWebStorage() override
+ {
+ }
+
+ void DeleteLocalFileSystem() override
+ {
+ }
+
+ void DisableCache( bool cacheDisabled ) override
+ {
+ }
+
+ void ClearCache() override
+ {
+ }
+
+private:
+ Dali::WebEngineContext::CacheModel mockModel;
+};
+
+class MockWebEngineCookieManager : public Dali::WebEngineCookieManager
+{
+public:
+ MockWebEngineCookieManager()
+ : mockCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY )
+ {
+ }
+
+ void SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy policy ) override
+ {
+ mockCookieAcceptPolicy = policy;
+ }
+
+ Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const override
+ {
+ return mockCookieAcceptPolicy;
+ }
+
+ void ClearCookies() override
+ {
+ }
+
+ void SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage ) override
+ {
+ }
+
+private:
+ Dali::WebEngineCookieManager::CookieAcceptPolicy mockCookieAcceptPolicy;
+};
+
+class MockWebEngineBackForwardListItem : public Dali::WebEngineBackForwardListItem
+{
+public:
+ MockWebEngineBackForwardListItem()
+ : mockUrl( "http://url" ),
+ mockTitle( "title" ),
+ mockOriginalUrl( "http://originalurl" )
+ {
+ }
+
+ std::string GetUrl() const override
+ {
+ return mockUrl;
+ }
+
+ std::string GetTitle() const override
+ {
+ return mockTitle;
+ }
+
+ std::string GetOriginalUrl() const override
+ {
+ return mockOriginalUrl;
+ }
+
+private:
+ std::string mockUrl;
+ std::string mockTitle;
+ std::string mockOriginalUrl;
+};
+
+class MockWebEngineBackForwardList : public Dali::WebEngineBackForwardList
+{
+public:
+ MockWebEngineBackForwardList( )
+ : mockItem(),
+ pMockItem( &mockItem )
+ {
+ }
+
+ Dali::WebEngineBackForwardListItem& GetCurrentItem() const override
+ {
+ return *pMockItem;
+ }
+
+ Dali::WebEngineBackForwardListItem& GetItemAtIndex( uint32_t index ) const override
+ {
+ return *pMockItem;
+ }
+
+ uint32_t GetItemCount() const override
+ {
+ return 1;
+ }
+
+private:
+ MockWebEngineBackForwardListItem mockItem;
+ WebEngineBackForwardListItem* pMockItem;
+};
+
+class MockWebEngineSettings : public WebEngineSettings
+{
+public:
+ MockWebEngineSettings()
+ : mockDefaultFontSize( 16 ),
+ mockJavaScriptEnabled( true ),
+ mockImageLoadedAutomatically( true ),
+ mockDefaultTextEncodingName()
+ {
+ }
+
+ uint32_t GetDefaultFontSize() const override
+ {
+ return mockDefaultFontSize;
+ }
+
+ void SetDefaultFontSize( uint32_t size ) override
+ {
+ mockDefaultFontSize = size;
+ }
+
+ bool IsJavaScriptEnabled() const override
+ {
+ return mockJavaScriptEnabled;
+ }
+
+ void EnableJavaScript( bool enabled ) override
+ {
+ mockJavaScriptEnabled = enabled;
+ }
+
+ bool AreImagesLoadedAutomatically() const override
+ {
+ return mockImageLoadedAutomatically;
+ }
+
+ void AllowImagesLoadAutomatically( bool automatic ) override
+ {
+ mockImageLoadedAutomatically = automatic;
+ }
+
+ std::string GetDefaultTextEncodingName() const override
+ {
+ return mockDefaultTextEncodingName;
+ }
+
+ void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) override
+ {
+ mockDefaultTextEncodingName = defaultTextEncodingName;
+ }
+
+ void AllowMixedContents( bool allowed ) override
+ {
+ }
+
+ void EnableSpatialNavigation( bool enabled ) override
+ {
+ }
+
+ void EnableWebSecurity( bool enabled ) override
+ {
+ }
+
+ void AllowFileAccessFromExternalUrl( bool allowed ) override
+ {
+ }
+
+ void AllowScriptsOpenWindows( bool allowed ) override
+ {
+ }
+
+private:
+ int mockDefaultFontSize;
+ bool mockJavaScriptEnabled;
+ bool mockImageLoadedAutomatically;
+ std::string mockDefaultTextEncodingName;
+};
+
class WebEngine: public Dali::BaseObject
{
public:
WebEngine()
: mUrl()
, mCurrentPlusOnePos( 0 )
- , mCacheModel( Dali::WebEnginePlugin::CacheModel::DOCUMENT_VIEWER )
- , mCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy::NO_THIRD_PARTY )
, mUserAgent()
- , mEnableJavaScript( true )
- , mLoadImagesAutomatically( true )
- , mDefaultTextEncodingName()
- , mDefaultFontSize( 16 )
, mEvaluating( false )
, mScrollPosition( 0, 0 )
, mScrollSize( 500, 500 )
{
gInstanceCount++;
gInstance = this;
+
+ mockWebEngineSettings = new MockWebEngineSettings();
+ mockWebEngineContext = new MockWebEngineContext();
+ mockWebEngineCookieManager = new MockWebEngineCookieManager();
+ mockWebEngineBackForwardList = new MockWebEngineBackForwardList();
}
virtual ~WebEngine()
{
gInstance = NULL;
}
+
+ delete mockWebEngineSettings;
+ delete mockWebEngineContext;
+ delete mockWebEngineCookieManager;
+ delete mockWebEngineBackForwardList;
+ }
+
+ Dali::WebEngineSettings& GetSettings() const
+ {
+ return *mockWebEngineSettings;
+ }
+
+ Dali::WebEngineContext& GetContext() const
+ {
+ return *mockWebEngineContext;
+ }
+
+ Dali::WebEngineCookieManager& GetCookieManager() const
+ {
+ return *mockWebEngineCookieManager;
+ }
+
+ Dali::WebEngineBackForwardList& GetBackForwardList() const
+ {
+ return *mockWebEngineBackForwardList;
}
void LoadUrl( const std::string& url )
ConnectToGlobalSignal( &OnClearHistory );
}
- Dali::WebEnginePlugin::CacheModel GetCacheModel() const
- {
- return mCacheModel;
- }
-
- void SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel )
- {
- mCacheModel = cacheModel;
- }
-
- Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const
- {
- return mCookieAcceptPolicy;
- }
-
- void SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy )
- {
- mCookieAcceptPolicy = policy;
- }
-
const std::string& GetUserAgent() const
{
return mUserAgent;
mUserAgent = userAgent;
}
- bool IsJavaScriptEnabled() const
- {
- return mEnableJavaScript;
- }
-
- void EnableJavaScript( bool enabled )
- {
- mEnableJavaScript = enabled;
- }
-
- bool AreImagesAutomaticallyLoaded() const
- {
- return mLoadImagesAutomatically;
- }
-
- void LoadImagesAutomatically( bool automatic )
- {
- mLoadImagesAutomatically = automatic;
- }
-
- const std::string& GetDefaultTextEncodingName() const
- {
- return mDefaultTextEncodingName;
- }
-
- void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
- {
- mDefaultTextEncodingName = defaultTextEncodingName;
- }
-
- int GetDefaultFontSize() const
- {
- return mDefaultFontSize;
- }
-
- void SetDefaultFontSize( int defaultFontSize )
- {
- mDefaultFontSize = defaultFontSize;
- }
-
void ScrollBy( int dx, int dy )
{
mScrollPosition += Dali::Vector2( dx, dy );
std::string mUrl;
std::vector< std::string > mHistory;
size_t mCurrentPlusOnePos;
- Dali::WebEnginePlugin::CacheModel mCacheModel;
- Dali::WebEnginePlugin::CookieAcceptPolicy mCookieAcceptPolicy;
std::string mUserAgent;
- bool mEnableJavaScript;
- bool mLoadImagesAutomatically;
- std::string mDefaultTextEncodingName;
- int mDefaultFontSize;
Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadStartedSignal;
Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadFinishedSignal;
Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType mPageLoadErrorSignal;
Dali::Vector2 mScrollPosition;
Dali::Vector2 mScrollSize;
Dali::Vector2 mContentSize;
+ WebEngineBackForwardList* mockWebEngineBackForwardList;
+ WebEngineContext* mockWebEngineContext;
+ WebEngineCookieManager* mockWebEngineCookieManager;
+ WebEngineSettings* mockWebEngineSettings;
};
inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
{
}
+WebEngineSettings& WebEngine::GetSettings() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetSettings();
+}
+
+WebEngineContext& WebEngine::GetContext() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetContext();
+}
+
+WebEngineCookieManager& WebEngine::GetCookieManager() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetCookieManager();
+}
+
+WebEngineBackForwardList& WebEngine::GetBackForwardList() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetBackForwardList();
+}
+
void WebEngine::LoadUrl( const std::string& url )
{
return Internal::Adaptor::GetImplementation( *this ).LoadUrl( url );
return sourcePtr;
}
-void WebEngine::LoadHTMLString( const std::string& htmlString )
+void WebEngine::LoadHtmlString( const std::string& htmlString )
{
}
Internal::Adaptor::GetImplementation( *this ).ClearHistory();
}
-void WebEngine::ClearCache()
-{
-}
-
-void WebEngine::ClearCookies()
-{
-}
-
-Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const
-{
- return Internal::Adaptor::GetImplementation( *this ).GetCacheModel();
-}
-
-void WebEngine::SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel )
-{
- Internal::Adaptor::GetImplementation( *this ).SetCacheModel( cacheModel );
-}
-
-Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const
-{
- return Internal::Adaptor::GetImplementation( *this ).GetCookieAcceptPolicy();
-}
-
-void WebEngine::SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy )
-{
- Internal::Adaptor::GetImplementation( *this ).SetCookieAcceptPolicy( policy );
-}
-
const std::string& WebEngine::GetUserAgent() const
{
return Internal::Adaptor::GetImplementation( *this ).GetUserAgent();
Internal::Adaptor::GetImplementation( *this ).SetUserAgent( userAgent );
}
-bool WebEngine::IsJavaScriptEnabled() const
-{
- return Internal::Adaptor::GetImplementation( *this ).IsJavaScriptEnabled();
-}
-
-void WebEngine::EnableJavaScript( bool enabled )
-{
- Internal::Adaptor::GetImplementation( *this ).EnableJavaScript( enabled );
-}
-
-bool WebEngine::AreImagesAutomaticallyLoaded() const
-{
- return Internal::Adaptor::GetImplementation( *this ).AreImagesAutomaticallyLoaded();
-}
-
-void WebEngine::LoadImagesAutomatically( bool automatic )
-{
- Internal::Adaptor::GetImplementation( *this ).LoadImagesAutomatically( automatic );
-}
-
-const std::string& WebEngine::GetDefaultTextEncodingName() const
-{
- return Internal::Adaptor::GetImplementation( *this ).GetDefaultTextEncodingName();
-}
-
-void WebEngine::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
-{
- Internal::Adaptor::GetImplementation( *this ).SetDefaultTextEncodingName( defaultTextEncodingName );
-}
-
-int WebEngine::GetDefaultFontSize() const
-{
- return Internal::Adaptor::GetImplementation( *this ).GetDefaultFontSize();
-}
-
-void WebEngine::SetDefaultFontSize( int defaultFontSize )
-{
- Internal::Adaptor::GetImplementation( *this ).SetDefaultFontSize( defaultFontSize );
-}
-
void WebEngine::ScrollBy( int dx, int dy )
{
Internal::Adaptor::GetImplementation( *this ).ScrollBy( dx, dy );
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
view.Reload();
view.StopLoading();
view.ClearHistory();
- view.ClearCache();
- view.ClearCookies();
Test::EmitGlobalTimerSignal();
DALI_TEST_CHECK( !view.CanGoBack() );
DALI_TEST_CHECK( !view.CanGoForward() );
END_TEST;
}
-int UtcDaliWebViewProperty1(void)
+int UtcDaliWebViewGetWebBackForwardList(void)
{
- // URL
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- std::string local;
- view.SetProperty( WebView::Property::URL, TEST_URL1 );
- Property::Value val = view.GetProperty( WebView::Property::URL );
- DALI_TEST_CHECK( val.Get( local ) );
- DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
+ Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
+ DALI_TEST_CHECK( bfList != 0 );
END_TEST;
}
-int UtcDaliWebViewProperty2(void)
+int UtcDaliWebViewGetWebContext(void)
{
- // CACHE_MODEL
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const std::string kDefaultValue = "DOCUMENT_VIEWER";
- const WebView::CacheModel::Type kTestEnum = WebView::CacheModel::PRIMARY_WEB_BROWSER;
- const std::string kTestValue = "PRIMARY_WEB_BROWSER";
-
- // Check default value
- std::string output;
- Property::Value value = view.GetProperty( WebView::Property::CACHE_MODEL );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
-
- // Check Set/GetProperty
- view.SetProperty( WebView::Property::CACHE_MODEL, kTestEnum );
- value = view.GetProperty( WebView::Property::CACHE_MODEL );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
-
- view.SetProperty( WebView::Property::CACHE_MODEL, kTestValue );
- value = view.GetProperty( WebView::Property::CACHE_MODEL );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ Dali::Toolkit::WebContext* context = view.GetContext();
+ DALI_TEST_CHECK( context != 0 );
END_TEST;
}
-int UtcDaliWebViewProperty3(void)
+int UtcDaliWebViewGetWebCookieManager(void)
{
- // COOKIE_ACCEPT_POLICY
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const std::string kDefaultValue = "NO_THIRD_PARTY";
- const WebView::CookieAcceptPolicy::Type kTestEnum = WebView::CookieAcceptPolicy::NEVER;
- const std::string kTestValue = "NEVER";
-
- // Check default value
- std::string output;
- Property::Value value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
-
- // Check Set/GetProperty
- view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestEnum );
- value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
-
- view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestValue );
- value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+ DALI_TEST_CHECK( cookieManager != 0 );
END_TEST;
}
-int UtcDaliWebViewProperty4(void)
+int UtcDaliWebViewGetWebSettings(void)
{
- // USER_AGENT
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const std::string kDefaultValue;
- const std::string kTestValue = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
-
- // Check default value
- std::string output;
- Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
-
- // Check Set/GetProperty
- view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
- value = view.GetProperty( WebView::Property::USER_AGENT );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 );
END_TEST;
}
-int UtcDaliWebViewProperty5(void)
-{
- // ENABLE_JAVASCRIPT
- ToolkitTestApplication application;
-
- WebView view = WebView::New();
- DALI_TEST_CHECK( view );
-
- const bool kDefaultValue = true;
- const bool kTestValue = false;
-
- // Check default value
- bool output;
- Property::Value value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
-
- // Check Set/GetProperty
- view.SetProperty( WebView::Property::ENABLE_JAVASCRIPT, kTestValue );
- value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliWebViewProperty6(void)
+int UtcDaliWebViewProperty1(void)
{
- // LOAD_IMAGES_AUTOMATICALLY
+ // URL
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const bool kDefaultValue = true;
- const bool kTestValue = false;
-
- // Check default value
- bool output;
- Property::Value value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
-
- // Check Set/GetProperty
- view.SetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY, kTestValue );
- value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ std::string local;
+ view.SetProperty( WebView::Property::URL, TEST_URL1 );
+ Property::Value val = view.GetProperty( WebView::Property::URL );
+ DALI_TEST_CHECK( val.Get( local ) );
+ DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
END_TEST;
}
-int UtcDaliWebViewProperty7(void)
+int UtcDaliWebViewProperty4(void)
{
- // DEFAULT_TEXT_ENCODING_NAME
+ // USER_AGENT
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
const std::string kDefaultValue;
- const std::string kTestValue = "UTF-8";
+ const std::string kTestValue = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
// Check default value
std::string output;
- Property::Value value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
-
- // Check Set/GetProperty
- view.SetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME, kTestValue );
- value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliWebViewProperty8(void)
-{
- // DEFAULT_FONT_SIZE
- ToolkitTestApplication application;
-
- WebView view = WebView::New();
- DALI_TEST_CHECK( view );
-
- const int kDefaultValue = 16;
- const int kTestValue = 26;
-
- // Check default value
- int output;
- Property::Value value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE );
+ Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
DALI_TEST_CHECK( value.Get( output ) );
DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::DEFAULT_FONT_SIZE, kTestValue );
- value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE );
+ view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
+ value = view.GetProperty( WebView::Property::USER_AGENT );
DALI_TEST_CHECK( value.Get( output ) );
DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
- view.LoadHTMLString( "<body>Hello World!</body>" );
+ view.LoadHtmlString( "<body>Hello World!</body>" );
view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
Test::EmitGlobalTimerSignal();
END_TEST;
}
-
int UtcDaliWebViewMethodsForCoverage(void)
{
ToolkitTestApplication application;
WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
- view.LoadHTMLString( "<body>Hello World!</body>" );
+ view.LoadHtmlString( "<body>Hello World!</body>" );
view.AddJavaScriptMessageHandler( "jsObject",
[]( const std::string& arg ) {
}
END_TEST;
}
+
+// test cases for web backforward list.
+
+int UtcDaliWebBackForwardListCheckItem(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
+ DALI_TEST_CHECK( bfList != 0 )
+
+ unsigned int itemCount = bfList->GetItemCount();
+ DALI_TEST_CHECK( itemCount == 1 )
+
+ Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem();
+ DALI_TEST_CHECK( citem != 0 );
+
+ const std::string kDefaultUrl( "http://url" );
+ std::string testValue = citem->GetUrl();
+ DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
+
+ const std::string kDefaultTitle( "title" );
+ testValue = citem->GetTitle();
+ DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
+
+ const std::string kDefaultOriginalUrl( "http://originalurl" );
+ testValue = citem->GetOriginalUrl();
+ DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
+
+ Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 );
+ DALI_TEST_CHECK( item != 0 );
+
+ END_TEST;
+}
+
+// test cases for web context.
+
+int UtcDaliWebContextGetSetCacheModel(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebContext* context = view.GetContext();
+ DALI_TEST_CHECK( context != 0 )
+
+ std::string kDefaultValue;
+
+ // Reset something
+ context->SetProxyUri( kDefaultValue );
+ context->SetCertificateFilePath( kDefaultValue );
+ context->DisableCache( false );
+ context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
+ context->DeleteWebDatabase();
+ context->DeleteWebStorage();
+ context->DeleteLocalFileSystem();
+ context->ClearCache();
+
+ // Check default value
+ Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
+ DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
+
+ // Check Set/GetProperty
+ context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
+ value = context->GetCacheModel();
+ DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
+
+ END_TEST;
+}
+
+// test cases for web cookie manager.
+
+int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+ DALI_TEST_CHECK( cookieManager != 0 )
+
+ const std::string kDefaultValue;
+
+ // Reset something
+ cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
+ cookieManager->ClearCookies();
+
+ // Check default value
+ Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
+ DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
+
+ // Check Set/GetProperty
+ cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
+ value = cookieManager->GetCookieAcceptPolicy();
+ DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
+
+ END_TEST;
+}
+
+// test cases for web settings.
+
+int UtcDaliWebSettingsGetSetDefaultFontSize(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+
+ // Check default value
+ int value = settings->GetDefaultFontSize();
+ DALI_TEST_CHECK( value == 16 );
+
+ // Check Set/GetProperty
+ settings->SetDefaultFontSize( 20 );
+ value = settings->GetDefaultFontSize();
+ DALI_TEST_CHECK( value == 20 );
+
+ END_TEST;
+}
+
+int UtcDaliWebSettingsCheckEnableJavaScript(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+
+ // Check default value is true or not
+ bool value = settings->IsJavaScriptEnabled();
+ DALI_TEST_CHECK( value );
+
+ // Check Set/GetProperty
+ settings->EnableJavaScript( false );
+ value = settings->IsJavaScriptEnabled();
+ DALI_TEST_CHECK( !value );
+
+ END_TEST;
+}
+
+int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+
+ // Check default value is true or not
+ bool value = settings->AreImagesLoadedAutomatically();
+ DALI_TEST_CHECK( value );
+
+ // Check Set/GetProperty
+ settings->AllowImagesLoadAutomatically( false );
+ value = settings->AreImagesLoadedAutomatically();
+ DALI_TEST_CHECK( !value );
+
+ END_TEST;
+}
+
+int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ const std::string kDefaultValue;
+ const std::string kTestValue = "UTF-8";
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+
+ // Check default value
+ std::string value = settings->GetDefaultTextEncodingName();
+ DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
+
+ // Check Set/GetProperty
+ settings->SetDefaultTextEncodingName( kTestValue );
+ value = settings->GetDefaultTextEncodingName();
+ DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
+
+ END_TEST;
+}
+
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+const std::string EMPTY_STRING;
+
+WebBackForwardListItem::WebBackForwardListItem( const Dali::WebEngineBackForwardListItem* item )
+: mWebEngineBackForwardListItem( item )
+{
+}
+
+WebBackForwardListItem::~WebBackForwardListItem()
+{
+}
+
+std::string WebBackForwardListItem::GetUrl() const
+{
+ return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetUrl() : EMPTY_STRING;
+}
+
+std::string WebBackForwardListItem::GetTitle() const
+{
+ return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetTitle() : EMPTY_STRING;
+}
+
+std::string WebBackForwardListItem::GetOriginalUrl() const
+{
+ return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetOriginalUrl() : EMPTY_STRING;
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
+#define DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+
+class WebEngineBackForwardListItem;
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebBackForwardListItem is a class for back-forward list item of WebView.
+ *
+ *
+ * For working WebBackForwardListItem, a Dali::WebBackForwardListItem should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebBackForwardListItem
+{
+public:
+ /**
+ * @brief Creates a WebBackForwardListItem.
+ */
+ WebBackForwardListItem( const Dali::WebEngineBackForwardListItem* item );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebBackForwardListItem() final;
+
+ /**
+ * @brief Returns the URL of the item.
+ *
+ * @details The returned URL may differ from the original URL (For example,
+ * if the page is redirected).
+ *
+ * @return The URL of the @a item, otherwise "" in case of an error
+ */
+ std::string GetUrl() const;
+
+ /**
+ * @brief Returns the title of the item.
+ *
+ * @return The title of the @a item, otherwise "" in case of an error
+ */
+ std::string GetTitle() const;
+
+ /**
+ * @brief Returns the original URL of the item.
+ *
+ * @return The original URL of the @a item, otherwise "" in case of an error
+ */
+ std::string GetOriginalUrl() const;
+
+private:
+
+ const Dali::WebEngineBackForwardListItem* mWebEngineBackForwardListItem;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebBackForwardList::WebBackForwardList( const Dali::WebEngineBackForwardList& list )
+: mWebEngineBackForwardList( list )
+, mWebBackForwardListItem( 0 )
+{
+}
+
+WebBackForwardList::~WebBackForwardList()
+{
+}
+
+WebBackForwardListItem* WebBackForwardList::GetCurrentItem()
+{
+ mWebBackForwardListItem = WebBackForwardListItem( &mWebEngineBackForwardList.GetCurrentItem() );
+ return &mWebBackForwardListItem;
+}
+
+WebBackForwardListItem* WebBackForwardList::GetItemAtIndex( uint32_t index )
+{
+ mWebBackForwardListItem = WebBackForwardListItem( &mWebEngineBackForwardList.GetItemAtIndex( index ) );
+ return &mWebBackForwardListItem;
+}
+
+uint32_t WebBackForwardList::GetItemCount() const
+{
+ return mWebEngineBackForwardList.GetItemCount();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H
+#define DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+
+class WebEngineBackForwardList;
+
+namespace Toolkit
+{
+class WebBackForwardListItem;
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebBackForwardList is a class for back-forward list item of WebView.
+ *
+ *
+ * For working WebBackForwardList, a Dali::WebBackForwardList should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebBackForwardList
+{
+public:
+ /**
+ * @brief Creates a WebBackForwardList.
+ */
+ WebBackForwardList( const Dali::WebEngineBackForwardList& list );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebBackForwardList() final;
+
+ /**
+ * @brief Returns the current item in the @a list.
+ * @return The current item in list.
+ */
+ WebBackForwardListItem* GetCurrentItem();
+
+ /**
+ * @brief Returns the item at a given @a index relative to the current item.
+ * @param[in] index The index of the item
+ * @return The current item in list.
+ */
+ WebBackForwardListItem* GetItemAtIndex(uint32_t index);
+
+ /**
+ * @brief Returns the length of the back-forward list including the current
+ * item.
+ * @return The length of the back-forward list including the current item,
+ * otherwise 0 in case of an error
+ */
+ uint32_t GetItemCount() const;
+
+private:
+ const Dali::WebEngineBackForwardList& mWebEngineBackForwardList;
+ Dali::Toolkit::WebBackForwardListItem mWebBackForwardListItem;
+
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebContext::WebContext( Dali::WebEngineContext& context)
+: mWebEngineContext( context )
+{
+}
+
+WebContext::~WebContext()
+{
+}
+
+Dali::WebEngineContext::CacheModel WebContext::GetCacheModel() const
+{
+ return mWebEngineContext.GetCacheModel();
+}
+
+void WebContext::SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel )
+{
+ mWebEngineContext.SetCacheModel( cacheModel );
+}
+
+void WebContext::SetProxyUri( const std::string& uri )
+{
+ mWebEngineContext.SetProxyUri( uri );
+}
+
+void WebContext::SetCertificateFilePath( const std::string& certificatePath )
+{
+ mWebEngineContext.SetCertificateFilePath( certificatePath );
+}
+
+void WebContext::DisableCache( bool cacheDisabled )
+{
+ mWebEngineContext.DisableCache( cacheDisabled );
+}
+
+void WebContext::SetDefaultProxyAuth( const std::string& username, const std::string& password )
+{
+ mWebEngineContext.SetDefaultProxyAuth( username, password );
+}
+
+void WebContext::DeleteWebDatabase()
+{
+ mWebEngineContext.DeleteWebDatabase();
+}
+
+void WebContext::DeleteWebStorage()
+{
+ mWebEngineContext.DeleteWebStorage();
+}
+
+void WebContext::DeleteLocalFileSystem()
+{
+ mWebEngineContext.DeleteLocalFileSystem();
+}
+
+void WebContext::ClearCache()
+{
+ mWebEngineContext.ClearCache();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_CONTEXT_H
+#define DALI_TOOLKIT_WEB_CONTEXT_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/devel-api/adaptor-framework/web-engine-context.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebContext is a control for settings of WebView.
+ *
+ * For working WebContext, a WebView should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebContext
+{
+public:
+
+ /**
+ * @brief Creates a WebContext.
+ *
+ * @param[in] context The context of web engine.
+ */
+ WebContext( Dali::WebEngineContext& context );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebContext() final;
+
+ /**
+ * @brief Returns the cache model type.
+ *
+ * @return #Dali::WebEngineContext::CacheModel
+ */
+ Dali::WebEngineContext::CacheModel GetCacheModel() const;
+
+ /**
+ * @brief Requests to set the cache model.
+ *
+ * @param[in] cacheModel The cache model
+ */
+ void SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel );
+
+ /**
+ * @brief Sets the given proxy URI to network backend of specific context.
+ *
+ * @param[in] uri The proxy URI to set
+ */
+ void SetProxyUri( const std::string& uri );
+
+ /**
+ * Adds CA certificates to persistent NSS certificate database
+ *
+ * Function accepts a path to a CA certificate file, a path to a directory
+ * containing CA certificate files, or a colon-seprarated list of those.
+ * Certificate files should have *.crt extension.
+ * Directories are traversed recursively.
+ *
+ * @param[in] certificatePath path to a CA certificate file(s), see above for details
+ */
+ void SetCertificateFilePath( const std::string& certificatePath );
+
+ /**
+ * Toggles the cache to be enabled or disabled
+ *
+ * Function works asynchronously.
+ * By default the cache is disabled resulting in not storing network data on disk.
+ *
+ * @param[in] cacheDisabled enable or disable cache
+ */
+ void DisableCache( bool cacheDisabled );
+
+ /**
+ * @brief Sets a proxy auth credential to network backend of specific context.
+ *
+ * @param[in] username username to set
+ * @param[in] password password to set
+ */
+ void SetDefaultProxyAuth( const std::string& username, const std::string& password );
+
+ /**
+ * Requests for deleting all web databases.
+ */
+ void DeleteWebDatabase();
+
+ /**
+ * @brief Deletes web storage.
+ *
+ * @details This function does not ensure that all data will be removed.
+ * Should be used to extend free physical memory.
+ */
+ void DeleteWebStorage();
+
+ /**
+ * @brief Requests for deleting all local file systems.
+ */
+ void DeleteLocalFileSystem();
+
+ /**
+ * @brief Requests to clear cache
+ */
+ void ClearCache();
+
+private:
+
+ Dali::WebEngineContext& mWebEngineContext;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_CONTEXT_H
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebCookieManager::WebCookieManager( Dali::WebEngineCookieManager& manager )
+: mWebEngineCookieManager( manager )
+{
+}
+
+WebCookieManager::~WebCookieManager()
+{
+}
+
+void WebCookieManager::SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy cookieAcceptPolicy )
+{
+ mWebEngineCookieManager.SetCookieAcceptPolicy( cookieAcceptPolicy );
+}
+
+Dali::WebEngineCookieManager::CookieAcceptPolicy WebCookieManager::GetCookieAcceptPolicy() const
+{
+ return mWebEngineCookieManager.GetCookieAcceptPolicy();
+}
+
+void WebCookieManager::ClearCookies()
+{
+ mWebEngineCookieManager.ClearCookies();
+}
+
+void WebCookieManager::SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage )
+{
+ mWebEngineCookieManager.SetPersistentStorage( path, storage );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_COOKIE_MANAGER_H
+#define DALI_TOOLKIT_WEB_COOKIE_MANAGER_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+class WebEngineCookieManager;
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebCookieManager is a control for settings of WebView.
+ *
+ *
+ * For working WebCookieManager, a WebView should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebCookieManager
+{
+public:
+
+ /**
+ * @brief Creates a WebCookieManager.
+ * @param[in] manager A #Dali::WebEngineCookieManager
+ */
+ WebCookieManager( Dali::WebEngineCookieManager& manager );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebCookieManager() final;
+
+ /**
+ * @brief Sets @a policy as the cookie acceptance policy for @a manager.
+ *
+ * @details By default, only cookies set by the main document loaded are
+ * accepted.
+ *
+ * @param[in] policy A #Dali::WebEngineCookieManager::CookieAcceptPolicy
+ */
+ void SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy policy );
+
+ /**
+ * @brief Gets the cookie acceptance policy. The default is Toolkit::WebCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY.
+ * @see Dali::WebEngineCookieManager::CookieAcceptPolicy
+ */
+ Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const;
+
+ /**
+ * @brief Deletes all the cookies of @a manager.
+ */
+ void ClearCookies();
+
+ /**
+ * @brief Sets the @a path where non-session cookies are stored persistently using
+ * @a storage as the format to read/write the cookies.
+ *
+ * @details Cookies are initially read from @a path/Cookies to create an initial
+ * set of cookies. Then, non-session cookies will be written to @a path/Cookies.
+ * By default, @a manager doesn't store the cookies persistently, so you need to
+ * call this method to keep cookies saved across sessions.
+ * If @a path does not exist it will be created.
+ *
+ * @param[in] path The path where to read/write Cookies
+ * @param[in] storage The type of storage
+ */
+ void SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage );
+
+private:
+
+ Dali::WebEngineCookieManager& mWebEngineCookieManager;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_COOKIE_MANAGER_H
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebSettings::WebSettings( Dali::WebEngineSettings& settings )
+: mWebEngineSettings( settings )
+{
+}
+
+WebSettings::~WebSettings()
+{
+}
+
+void WebSettings::AllowMixedContents( bool allowed )
+{
+ mWebEngineSettings.AllowMixedContents( allowed );
+}
+
+void WebSettings::EnableSpatialNavigation( bool enabled )
+{
+ mWebEngineSettings.AllowMixedContents( enabled );
+}
+
+int WebSettings::GetDefaultFontSize() const
+{
+ return mWebEngineSettings.GetDefaultFontSize();
+}
+
+void WebSettings::SetDefaultFontSize( int defaultFontSize )
+{
+ mWebEngineSettings.SetDefaultFontSize( defaultFontSize );
+}
+
+void WebSettings::EnableWebSecurity( bool enabled )
+{
+ mWebEngineSettings.EnableWebSecurity( enabled );
+}
+
+void WebSettings::AllowFileAccessFromExternalUrl( bool allowed )
+{
+ mWebEngineSettings.AllowFileAccessFromExternalUrl( allowed );
+}
+
+bool WebSettings::IsJavaScriptEnabled() const
+{
+ return mWebEngineSettings.IsJavaScriptEnabled();
+}
+
+void WebSettings::EnableJavaScript( bool enabled )
+{
+ mWebEngineSettings.EnableJavaScript( enabled );
+}
+
+void WebSettings::AllowScriptsOpenWindows( bool allowed )
+{
+ mWebEngineSettings.AllowScriptsOpenWindows( allowed );
+}
+
+bool WebSettings::AreImagesLoadedAutomatically() const
+{
+ return mWebEngineSettings.AreImagesLoadedAutomatically();
+}
+
+void WebSettings::AllowImagesLoadAutomatically( bool automatic )
+{
+ mWebEngineSettings.AllowImagesLoadAutomatically( automatic );
+}
+
+std::string WebSettings::GetDefaultTextEncodingName() const
+{
+ return mWebEngineSettings.GetDefaultTextEncodingName();
+}
+
+void WebSettings::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
+{
+ mWebEngineSettings.SetDefaultTextEncodingName( defaultTextEncodingName );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_SETTINGS_H
+#define DALI_TOOLKIT_WEB_SETTINGS_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+class WebEngineSettings;
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebEngineSettings is a control for settings of WebView.
+ *
+ *
+ * For working WebEngineSettings, a WebView should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebSettings
+{
+public:
+ /**
+ * @brief Creates a WebEngineSettings.
+ *
+ * @param[in] settings A settings of web engine.
+ */
+ WebSettings( Dali::WebEngineSettings& settings );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebSettings() final;
+
+ /**
+ *@brief Allow running mixed contents or not.
+ *
+ * @param[in] allowed if true, allow to run mixed contents,
+ * otherwise not allow
+ */
+ void AllowMixedContents( bool allowed );
+
+ /**
+ * @brief Enable the spatial navigation or not.
+ *
+ * @param[in] enabled if true, use spatial navigation,
+ * otherwise to disable
+ */
+ void EnableSpatialNavigation( bool enabled );
+
+ /**
+ * @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 Enables/disables web security.
+ *
+ * @param[in] enabled if true, to enable the web security
+ * otherwise to disable
+ */
+ void EnableWebSecurity( bool enabled );
+
+ /**
+ * @brief Allow/Disallow file access from external url
+ *
+ * @param[in] allowed if true, to allow file access from external url
+ * otherwise to disallow
+ */
+ void AllowFileAccessFromExternalUrl( bool allowed );
+
+ /**
+ * @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 Allow if the scripts can open new windows.
+ *
+ * @param[in] allowed if true, the scripts can open new windows,
+ * otherwise not
+ */
+ void AllowScriptsOpenWindows( bool allowed );
+
+ /**
+ * @brief Returns whether images can be loaded automatically. The default is true.
+ *
+ * @return true if images are loaded automatically, false otherwise
+ */
+ bool AreImagesLoadedAutomatically() const;
+
+ /**
+ * @brief Enables/disables auto loading of images. The default is enabled.
+ *
+ * @param[in] automatic True if images are loaded automatically, false otherwise
+ */
+ void AllowImagesLoadAutomatically( bool automatic );
+
+ /**
+ * @brief Gets the default text encoding name (e.g. UTF-8).
+ *
+ * @return The default text encoding name
+ */
+ std::string GetDefaultTextEncodingName() const;
+
+ /**
+ * @brief Sets the default text encoding name (e.g. UTF-8).
+ *
+ * @param[in] defaultTextEncodingName The default text encoding name
+ */
+ void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName );
+
+private:
+ Dali::WebEngineSettings& mWebEngineSettings;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_SETTINGS_H
return Control::DownCast<WebView, Internal::WebView>(handle);
}
+Dali::Toolkit::WebSettings* WebView::GetSettings() const
+{
+ return Dali::Toolkit::GetImpl( *this ).GetSettings();
+}
+
+Dali::Toolkit::WebContext* WebView::GetContext() const
+{
+ return Dali::Toolkit::GetImpl( *this ).GetContext();
+}
+
+Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const
+{
+ return Dali::Toolkit::GetImpl( *this ).GetCookieManager();
+}
+
+Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
+{
+ return Dali::Toolkit::GetImpl( *this ).GetBackForwardList();
+}
+
void WebView::LoadUrl(const std::string& url)
{
Dali::Toolkit::GetImpl(*this).LoadUrl(url);
}
-void WebView::LoadHTMLString(const std::string& htmlString)
+void WebView::LoadHtmlString(const std::string& htmlString)
{
- Dali::Toolkit::GetImpl(*this).LoadHTMLString(htmlString);
+ Dali::Toolkit::GetImpl(*this).LoadHtmlString(htmlString);
}
void WebView::Reload()
Dali::Toolkit::GetImpl(*this).ClearHistory();
}
-void WebView::ClearCache()
-{
- Dali::Toolkit::GetImpl(*this).ClearCache();
-}
-
-void WebView::ClearCookies()
-{
- Dali::Toolkit::GetImpl(*this).ClearCookies();
-}
-
WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
{
return Dali::Toolkit::GetImpl(*this).PageLoadStartedSignal();
{
namespace Toolkit
{
+class WebBackForwardList;
+class WebContext;
+class WebCookieManager;
+class WebSettings;
+
namespace Internal DALI_INTERNAL
{
class WebView;
class DALI_TOOLKIT_API WebView : public Control
{
public:
- /**
- * @brief A structure used to contain the cache model enumeration.
- */
- struct CacheModel
- {
- /**
- * @brief Enumeration for cache model options.
- */
- enum Type
- {
- /**
- * @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 A structure used to contain the cookie acceptance policy enumeration.
- */
- struct CookieAcceptPolicy
- {
- /**
- * @brief Enumeration for the cookies accept policies.
- */
- enum Type
- {
- /**
- * @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 Enumeration for the start and end property ranges for this control.
URL = PROPERTY_START_INDEX,
/**
- * @brief The cache model.
- * @details Name "cacheModel", type WebView::CacheModel::Type (Property::INTEGER) or Property::STRING.
- * @note Default is WebView::CacheModel::DOCUMENT_VIEWER.
- * @see WebView::CacheModel::Type
- */
- CACHE_MODEL,
-
- /**
- * @brief The cookie acceptance policy.
- * @details Name "cookieAcceptPolicy", type WebView::CookieAcceptPolicy::Type (Property::INTEGER) or Property::STRING.
- * @note Default is WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
- * @see WebView::CookieAcceptPolicy::Type
- */
- COOKIE_ACCEPT_POLICY,
-
- /**
* @brief The user agent string.
* @details Name "userAgent", type Property::STRING.
*/
USER_AGENT,
/**
- * @brief Whether JavaScript is enabled.
- * @details Name "enableJavaScript", type Property::BOOLEAN.
- * @note Default is true.
- */
- ENABLE_JAVASCRIPT,
-
- /**
- * @brief Whether images can be loaded automatically.
- * @details Name "loadImagesAutomatically", type Property::BOOLEAN.
- * @note Default is true.
- */
- LOAD_IMAGES_AUTOMATICALLY,
-
- /**
- * @brief The default text encoding name.
- * @details Name "defaultTextEncodingName", type Property::STRING.
- * @note If the value is not set, the web engine detects web page's text encoding.
- */
- DEFAULT_TEXT_ENCODING_NAME,
-
- /**
- * @brief The default font size in pixel.
- * @details Name "defaultFontSize", type Property::INT.
- * @note Default is 16.
- */
- DEFAULT_FONT_SIZE,
-
- /**
* @brief The current position of scroll.
* @details Name "scrollPosition", type Property::VECTOR2.
*/
static WebView DownCast(BaseHandle handle);
/**
+ * @brief Get WebSettings of WebEngine.
+ */
+ Dali::Toolkit::WebSettings* GetSettings() const;
+
+ /**
+ * @brief Get WebContext of WebEngine.
+ */
+ Dali::Toolkit::WebContext* GetContext() const;
+
+ /**
+ * @brief Get CookieManager of WebEngine.
+ */
+ Dali::Toolkit::WebCookieManager* GetCookieManager() const;
+
+ /**
+ * @brief Get WebBackForwardList of WebEngine.
+ */
+ Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
+
+ /**
* @brief Loads a web page based on a given URL.
*
* @param [in] url The URL of the resource to load
*
* @param [in] htmlString The string to use as the contents of the web page
*/
- void LoadHTMLString(const std::string& htmlString);
+ void LoadHtmlString(const std::string& htmlString);
/**
* @brief Reloads the Web.
void ClearHistory();
/**
- * @brief Clears the cache of Web.
- */
- void ClearCache();
-
- /**
- * @brief Clears all the cookies of Web.
- */
- void ClearCookies();
-
- /**
* @brief Connects to this signal to be notified when page loading is started.
*
* @return A signal object to connect with
${devel_api_src_dir}/controls/text-controls/text-selection-toolbar.cpp
${devel_api_src_dir}/controls/tool-bar/tool-bar.cpp
${devel_api_src_dir}/controls/video-view/video-view-devel.cpp
+ ${devel_api_src_dir}/controls/web-view/web-back-forward-list.cpp
+ ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.cpp
+ ${devel_api_src_dir}/controls/web-view/web-context.cpp
+ ${devel_api_src_dir}/controls/web-view/web-cookie-manager.cpp
+ ${devel_api_src_dir}/controls/web-view/web-settings.cpp
${devel_api_src_dir}/controls/web-view/web-view.cpp
${devel_api_src_dir}/focus-manager/keyinput-focus-manager.cpp
${devel_api_src_dir}/focus-manager/keyboard-focus-manager-devel.cpp
)
SET( devel_api_web_view_header_files
+ ${devel_api_src_dir}/controls/web-view/web-back-forward-list.h
+ ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.h
+ ${devel_api_src_dir}/controls/web-view/web-context.h
+ ${devel_api_src_dir}/controls/web-view/web-cookie-manager.h
+ ${devel_api_src_dir}/controls/web-view/web-settings.h
${devel_api_src_dir}/controls/web-view/web-view.h
)
// EXTERNAL INCLUDES
#include <cstring>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine-context.h>
+#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/devel-api/common/stage.h>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/image-loader/texture-manager.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
return Toolkit::WebView::New();
}
-DALI_ENUM_TO_STRING_TABLE_BEGIN( CacheModel )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_VIEWER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_BROWSER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, PRIMARY_WEB_BROWSER )
-DALI_ENUM_TO_STRING_TABLE_END( CacheModel )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( CookieAcceptPolicy )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, ALWAYS )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NEVER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NO_THIRD_PARTY )
-DALI_ENUM_TO_STRING_TABLE_END( CookieAcceptPolicy )
-
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url", STRING, URL )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cacheModel", STRING, CACHE_MODEL )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cookieAcceptPolicy", STRING, COOKIE_ACCEPT_POLICY )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "userAgent", STRING, USER_AGENT )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "enableJavaScript", BOOLEAN, ENABLE_JAVASCRIPT )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "loadImagesAutomatically", BOOLEAN, LOAD_IMAGES_AUTOMATICALLY )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultTextEncodingName", STRING, DEFAULT_TEXT_ENCODING_NAME )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultFontSize", INTEGER, DEFAULT_FONT_SIZE )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollPosition", VECTOR2, SCROLL_POSITION )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollSize", VECTOR2, SCROLL_SIZE )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "contentSize", VECTOR2, CONTENT_SIZE )
mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError );
mWebEngine.ScrollEdgeReachedSignal().Connect( this, &WebView::OnScrollEdgeReached );
+
+ mWebContext = std::unique_ptr<Dali::Toolkit::WebContext>( new WebContext( mWebEngine.GetContext() ) );
+ mWebCookieManager = std::unique_ptr<Dali::Toolkit::WebCookieManager>( new WebCookieManager( mWebEngine.GetCookieManager() ) );
+ mWebSettings = std::unique_ptr<Dali::Toolkit::WebSettings>( new WebSettings( mWebEngine.GetSettings() ) );
+ mWebBackForwardList = std::unique_ptr<Dali::Toolkit::WebBackForwardList>( new WebBackForwardList( mWebEngine.GetBackForwardList() ) );
}
}
+Dali::Toolkit::WebSettings* WebView::GetSettings() const
+{
+ return mWebSettings.get();
+}
+
+Dali::Toolkit::WebContext* WebView::GetContext() const
+{
+ return mWebContext.get();
+}
+
+Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const
+{
+ return mWebCookieManager.get();
+}
+
+Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
+{
+ return mWebBackForwardList.get();
+}
+
void WebView::LoadUrl( const std::string& url )
{
mUrl = url;
}
}
-void WebView::LoadHTMLString( const std::string& htmlString )
+void WebView::LoadHtmlString( const std::string& htmlString )
{
if( mWebEngine )
{
if( mVisual )
{
DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
- mWebEngine.LoadHTMLString( htmlString );
+ mWebEngine.LoadHtmlString( htmlString );
}
}
}
}
}
-void WebView::ClearCache()
-{
- if( mWebEngine )
- {
- mWebEngine.ClearCache();
- }
-}
-
-void WebView::ClearCookies()
-{
- if( mWebEngine )
- {
- mWebEngine.ClearCookies();
- }
-}
-
Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
{
return mPageLoadStartedSignal;
}
break;
}
- case Toolkit::WebView::Property::CACHE_MODEL:
- {
- Toolkit::WebView::CacheModel::Type output = impl.GetCacheModel();
- GET_ENUM_VALUE( CacheModel, value, output );
- impl.SetCacheModel( output );
- break;
- }
- case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
- {
- Toolkit::WebView::CookieAcceptPolicy::Type output = impl.GetCookieAcceptPolicy();
- GET_ENUM_VALUE( CookieAcceptPolicy, value, output );
- impl.SetCookieAcceptPolicy( output );
- break;
- }
case Toolkit::WebView::Property::USER_AGENT:
{
std::string input;
}
break;
}
- case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
- {
- bool input;
- if( value.Get( input ) )
- {
- impl.EnableJavaScript( input );
- }
- break;
- }
- case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
- {
- bool input;
- if( value.Get( input ) )
- {
- impl.LoadImagesAutomatically( input );
- }
- break;
- }
- case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
- {
- std::string input;
- if( value.Get( input ) )
- {
- impl.SetDefaultTextEncodingName( input );
- }
- break;
- }
- case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
- {
- int input;
- if( value.Get( input ) )
- {
- impl.SetDefaultFontSize( input );
- }
- break;
- }
case Toolkit::WebView::Property::SCROLL_POSITION:
{
Vector2 input;
value = impl.mUrl;
break;
}
- case Toolkit::WebView::Property::CACHE_MODEL:
- {
- value = GET_ENUM_STRING( CacheModel, impl.GetCacheModel() );
- break;
- }
- case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
- {
- value = GET_ENUM_STRING( CookieAcceptPolicy, impl.GetCookieAcceptPolicy() );
- break;
- }
case Toolkit::WebView::Property::USER_AGENT:
{
value = impl.GetUserAgent();
break;
}
- case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
- {
- value = impl.IsJavaScriptEnabled();
- break;
- }
- case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
- {
- value = impl.AreImagesAutomaticallyLoaded();
- break;
- }
- case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
- {
- value = impl.GetDefaultTextEncodingName();
- break;
- }
- case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
- {
- value = impl.GetDefaultFontSize();
- break;
- }
case Toolkit::WebView::Property::SCROLL_POSITION:
{
int x, y;
}
}
-Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const
-{
- return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER;
-}
-
-void WebView::SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel )
-{
- if( mWebEngine )
- {
- mWebEngine.SetCacheModel( static_cast< WebEnginePlugin::CacheModel >( cacheModel ) );
- }
-}
-
-Toolkit::WebView::CookieAcceptPolicy::Type WebView::GetCookieAcceptPolicy() const
-{
- return mWebEngine ? static_cast< Toolkit::WebView::CookieAcceptPolicy::Type >( mWebEngine.GetCookieAcceptPolicy() ) : Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY;
-}
-
-void WebView::SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy )
-{
- if( mWebEngine )
- {
- mWebEngine.SetCookieAcceptPolicy( static_cast< WebEnginePlugin::CookieAcceptPolicy >( policy ) );
- }
-}
-
const std::string& WebView::GetUserAgent() const
{
return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
}
}
-bool WebView::IsJavaScriptEnabled() const
-{
- return mWebEngine ? mWebEngine.IsJavaScriptEnabled() : true;
-}
-
-void WebView::EnableJavaScript( bool enabled )
-{
- if( mWebEngine )
- {
- mWebEngine.EnableJavaScript( enabled );
- }
-}
-
-bool WebView::AreImagesAutomaticallyLoaded() const
-{
- return mWebEngine ? mWebEngine.AreImagesAutomaticallyLoaded() : true;
-}
-
-void WebView::LoadImagesAutomatically( bool automatic )
-{
- if( mWebEngine )
- {
- mWebEngine.LoadImagesAutomatically( automatic );
- }
-}
-
-const std::string& WebView::GetDefaultTextEncodingName() const
-{
- return mWebEngine ? mWebEngine.GetDefaultTextEncodingName() : kEmptyString;
-}
-
-void WebView::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
-{
- if( mWebEngine )
- {
- mWebEngine.SetDefaultTextEncodingName( defaultTextEncodingName );
- }
-}
-
-int WebView::GetDefaultFontSize() const
-{
- return mWebEngine ? mWebEngine.GetDefaultFontSize() : 0;
-}
-
-void WebView::SetDefaultFontSize( int defaultFontSize )
-{
- if( mWebEngine )
- {
- mWebEngine.SetDefaultFontSize( defaultFontSize );
- }
-}
-
#undef GET_ENUM_STRING
#undef GET_ENUM_VALUE
*/
// EXTERNAL INCLUDES
+#include <memory>
#include <dali/devel-api/adaptor-framework/web-engine.h>
#include <dali/public-api/images/image-operations.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>
namespace Dali
{
class KeyEvent;
class TouchEvent;
+class WebBackForwardList;
+class WebContext;
+class WebCookieManager;
+class WebSettings;
class WebView;
namespace Internal
static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId );
/**
+ * @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::LoadUrl()
*/
void LoadUrl( const std::string& url );
/**
* @copydoc Dali::WebEngine::LoadHTMLString()
*/
- void LoadHTMLString( const std::string& htmlString );
+ void LoadHtmlString( const std::string& htmlString );
/**
* @copydoc Dali::Toolkit::WebView::Reload()
void ClearHistory();
/**
- * @copydoc Dali::Toolkit::WebView::ClearCache()
- */
- void ClearCache();
-
- /**
- * @copydoc Dali::Toolkit::WebView::ClearCookies()
- */
- void ClearCookies();
-
- /**
* @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
*/
Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadStartedSignal();
void GetContentSize( int& width, int& height ) const;
/**
- * @brief Get cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
- * @see Toolkit::WebView::CacheModel::Type
- */
- Toolkit::WebView::CacheModel::Type GetCacheModel() const;
-
- /**
- * @brief Set cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
- * @param[in] cacheModel The cache model option
- * @see Toolkit::WebView::CacheModel::Type
- */
- void SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel );
-
- /**
- * @brief Gets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
- * @see Toolkit::WebView::CookieAcceptPolicy::Type
- */
- Toolkit::WebView::CookieAcceptPolicy::Type GetCookieAcceptPolicy() const;
-
- /**
- * @brief Sets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
- * @param[in] policy The cookie acceptance policy
- * @see Toolkit::WebView::CookieAcceptPolicy::Type
- */
- void SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy );
-
- /**
* @brief Get user agent string.
* @return 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 images can be loaded automatically. 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 (e.g. UTF-8).
- *
- * @return The default text encoding name
- */
- const std::string& GetDefaultTextEncodingName() const;
-
- /**
- * @brief Sets the default text encoding name (e.g. UTF-8).
- *
- * @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 Callback function to be called when page load started.
* @param[in] url The url currently being loaded
*/
Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadFinishedSignal;
Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal;
Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+
+ 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;
};
} // namespace Internal