/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/environment-variable.h>
+#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/internal/system/common/environment-variables.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/images/pixel-data.h>
namespace Dali
{
namespace // unnamed namespace
{
-constexpr char const * const kPluginFullNamePrefix = "libdali-web-engine-";
+constexpr char const * const kPluginFullNamePrefix = "libdali2-web-engine-";
constexpr char const * const kPluginFullNamePostfix = "-plugin.so";
-constexpr char const * const kPluginFullNameDefault = "libdali-web-engine-plugin.so";
+constexpr char const * const kPluginFullNameDefault = "libdali2-web-engine-plugin.so";
// Note: Dali WebView policy does not allow to use multiple web engines in an application.
// So once pluginName is set to non-empty string, it will not change.
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()
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;
}
}
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;
{
char* error = NULL;
- if ( !InitializePluginHandle() )
+ if( !InitializePluginHandle() )
{
return false;
}
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;
}
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::Create( int width, int height, int argc, char** argv )
+{
+ mPlugin->Create( width, height, argc, argv );
}
void WebEngine::Destroy()
{
- if( mPlugin != NULL )
- {
- mPlugin->Destroy();
- }
+ mPlugin->Destroy();
}
Dali::NativeImageInterfacePtr WebEngine::GetNativeImageSource()
return mPlugin->GetNativeImageSource();
}
+Dali::WebEngineSettings& WebEngine::GetSettings() const
+{
+ return mPlugin->GetSettings();
+}
+
+Dali::WebEngineContext& WebEngine::GetContext() const
+{
+ return mPlugin->GetContext();
+}
+
+Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
+{
+ return mPlugin->GetCookieManager();
+}
+
+Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
+{
+ return mPlugin->GetBackForwardList();
+}
+
void WebEngine::LoadUrl( const std::string& url )
{
- if( mPlugin != NULL )
- {
- mPlugin->LoadUrl( url );
- }
+ mPlugin->LoadUrl( url );
+}
+
+std::string WebEngine::GetTitle() const
+{
+ return mPlugin->GetTitle();
+}
+
+Dali::PixelData WebEngine::GetFavicon() const
+{
+ return mPlugin->GetFavicon();
}
const std::string& WebEngine::GetUrl()
{
- static std::string emptyUrl;
- return mPlugin ? mPlugin->GetUrl() : emptyUrl;
+ return mPlugin->GetUrl();
}
-void WebEngine::LoadHTMLString( const std::string& htmlString )
+const std::string& WebEngine::GetUserAgent() const
{
- if( mPlugin != NULL )
- {
- mPlugin->LoadHTMLString( htmlString );
- }
+ return mPlugin->GetUserAgent();
+}
+
+void WebEngine::SetUserAgent( const std::string& userAgent )
+{
+ mPlugin->SetUserAgent( userAgent );
+}
+
+void WebEngine::LoadHtmlString( const std::string& 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();
+}
+
+void WebEngine::ScrollBy( int deltaX, int deltaY )
+{
+ mPlugin->ScrollBy( deltaX, deltaY );
+}
+
+void WebEngine::SetScrollPosition( int x, int y )
+{
+ mPlugin->SetScrollPosition( x, y );
+}
+
+void WebEngine::GetScrollPosition( int& x, int& y ) const
+{
+ mPlugin->GetScrollPosition( x, y );
+}
+
+void WebEngine::GetScrollSize( int& width, int& height ) const
+{
+ mPlugin->GetScrollSize( width, height );
+}
+
+void WebEngine::GetContentSize( int& width, int& height ) const
+{
+ mPlugin->GetContentSize( width, height );
}
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()
+void WebEngine::ClearAllTilesResources()
{
- if( mPlugin != NULL )
- {
- mPlugin->ClearHistory();
- }
+ mPlugin->ClearAllTilesResources();
}
-void WebEngine::ClearCache()
+void WebEngine::ClearHistory()
{
- if( mPlugin != NULL )
- {
- mPlugin->ClearCache();
- }
+ mPlugin->ClearHistory();
}
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 )
+bool WebEngine::SendTouchEvent( const Dali::TouchEvent& 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 mPlugin->SendKeyEvent( event );
+}
- return false;
+void WebEngine::SetFocus( bool focused )
+{
+ mPlugin->SetFocus( focused );
}
-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();
+}
+
+Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
+{
+ return mPlugin->ScrollEdgeReachedSignal();
+}
+
} // namespace Adaptor;
} // namespace Internal;
} // namespace Dali;
+