X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fweb-engine%2Fcommon%2Fweb-engine-impl.cpp;h=257b067694f33ff0f87ec0b7c5271194fd57f4eb;hb=5e107006fc541ce919d678785c54b314e7ba6c4e;hp=c058c630618297413d8e3a9cc15c8d61b1389a63;hpb=0b9a2d99cea6c0da882cedf22dfd066a913befe4;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/web-engine/common/web-engine-impl.cpp b/dali/internal/web-engine/common/web-engine-impl.cpp old mode 100644 new mode 100755 index c058c63..257b067 --- a/dali/internal/web-engine/common/web-engine-impl.cpp +++ b/dali/internal/web-engine/common/web-engine-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,41 +19,42 @@ #include // EXTERNAL INCLUDES -#include #include #include +#include #include // INTERNAL INCLUDES #include +#include +#include +#include +#include #include #include +#include namespace Dali { - namespace Internal { - namespace Adaptor { - namespace // unnamed namespace { - -constexpr char const * const kPluginFullNamePrefix = "libdali2-web-engine-"; -constexpr char const * const kPluginFullNamePostfix = "-plugin.so"; -constexpr char const * const kPluginFullNameDefault = "libdali2-web-engine-plugin.so"; +constexpr char const* const kPluginFullNamePrefix = "libdali2-web-engine-"; +constexpr char const* const kPluginFullNamePostfix = "-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. std::string pluginName; -std::string MakePluginName( const char* environmentName ) +std::string MakePluginName(const char* environmentName) { std::stringstream fullName; fullName << kPluginFullNamePrefix << environmentName << kPluginFullNamePostfix; - return std::move( fullName.str() ); + return std::move(fullName.str()); } Dali::BaseHandle Create() @@ -61,7 +62,7 @@ Dali::BaseHandle Create() return Dali::WebEngine::New(); } -Dali::TypeRegistration type( typeid( Dali::WebEngine ), typeid( Dali::BaseHandle ), Create ); +Dali::TypeRegistration type(typeid(Dali::WebEngine), typeid(Dali::BaseHandle), Create); } // unnamed namespace @@ -69,7 +70,7 @@ WebEnginePtr WebEngine::New() { WebEngine* instance = new WebEngine(); - if( !instance->Initialize() ) + if(!instance->Initialize()) { delete instance; return nullptr; @@ -79,49 +80,49 @@ WebEnginePtr WebEngine::New() } WebEngine::WebEngine() -: mPlugin( NULL ), - mHandle( NULL ), - mCreateWebEnginePtr( NULL ), - mDestroyWebEnginePtr( NULL ) +: mPlugin(NULL), + mHandle(NULL), + mCreateWebEnginePtr(NULL), + mDestroyWebEnginePtr(NULL) { } WebEngine::~WebEngine() { - if( mHandle != NULL ) + if(mHandle != NULL) { - if( mDestroyWebEnginePtr != NULL ) + if(mDestroyWebEnginePtr != NULL) { mPlugin->Destroy(); - mDestroyWebEnginePtr( mPlugin ); + mDestroyWebEnginePtr(mPlugin); } - dlclose( mHandle ); + dlclose(mHandle); } } 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 ) + const char* name = EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_WEB_ENGINE_NAME); + if(name) { - pluginName = MakePluginName( name ); - mHandle = dlopen( pluginName.c_str(), RTLD_LAZY ); - if( mHandle ) + pluginName = MakePluginName(name); + mHandle = dlopen(pluginName.c_str(), RTLD_LAZY); + if(mHandle) { return true; } } - pluginName = std::string( kPluginFullNameDefault ); + pluginName = std::string(kPluginFullNameDefault); } - mHandle = dlopen( pluginName.c_str(), RTLD_LAZY ); - if( !mHandle ) + mHandle = dlopen(pluginName.c_str(), RTLD_LAZY); + if(!mHandle) { - DALI_LOG_ERROR( "Can't load %s : %s\n", pluginName.c_str(), dlerror() ); + DALI_LOG_ERROR("Can't load %s : %s\n", pluginName.c_str(), dlerror()); return false; } @@ -132,40 +133,45 @@ bool WebEngine::Initialize() { char* error = NULL; - if( !InitializePluginHandle() ) + if(!InitializePluginHandle()) { return false; } - mCreateWebEnginePtr = reinterpret_cast< CreateWebEngineFunction >( dlsym( mHandle, "CreateWebEnginePlugin" ) ); - if( mCreateWebEnginePtr == NULL ) + mCreateWebEnginePtr = reinterpret_cast(dlsym(mHandle, "CreateWebEnginePlugin")); + if(mCreateWebEnginePtr == NULL) { - DALI_LOG_ERROR( "Can't load symbol CreateWebEnginePlugin(), error: %s\n", error ); + DALI_LOG_ERROR("Can't load symbol CreateWebEnginePlugin(), error: %s\n", error); return false; } - mDestroyWebEnginePtr = reinterpret_cast< DestroyWebEngineFunction >( dlsym( mHandle, "DestroyWebEnginePlugin" ) ); + mDestroyWebEnginePtr = reinterpret_cast(dlsym(mHandle, "DestroyWebEnginePlugin")); - if( mDestroyWebEnginePtr == NULL ) + if(mDestroyWebEnginePtr == NULL) { - DALI_LOG_ERROR( "Can't load symbol DestroyWebEnginePlugin(), error: %s\n", error ); + DALI_LOG_ERROR("Can't load symbol DestroyWebEnginePlugin(), error: %s\n", error); return false; } mPlugin = mCreateWebEnginePtr(); - if( mPlugin == NULL ) + if(mPlugin == NULL) { - DALI_LOG_ERROR( "Can't create the WebEnginePlugin object\n" ); + DALI_LOG_ERROR("Can't create the WebEnginePlugin object\n"); return false; } return true; } -void WebEngine::Create( int width, int height, const std::string& locale, const std::string& timezoneId ) +void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId) { - 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() @@ -178,9 +184,39 @@ Dali::NativeImageInterfacePtr WebEngine::GetNativeImageSource() return mPlugin->GetNativeImageSource(); } -void WebEngine::LoadUrl( const std::string& url ) +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) +{ + mPlugin->LoadUrl(url); +} + +std::string WebEngine::GetTitle() const +{ + return mPlugin->GetTitle(); +} + +Dali::PixelData WebEngine::GetFavicon() const { - mPlugin->LoadUrl( url ); + return mPlugin->GetFavicon(); } const std::string& WebEngine::GetUrl() @@ -188,9 +224,19 @@ const std::string& WebEngine::GetUrl() return mPlugin->GetUrl(); } -void WebEngine::LoadHTMLString( const std::string& htmlString ) +const std::string& WebEngine::GetUserAgent() const +{ + return mPlugin->GetUserAgent(); +} + +void WebEngine::SetUserAgent(const std::string& userAgent) +{ + mPlugin->SetUserAgent(userAgent); +} + +void WebEngine::LoadHtmlString(const std::string& htmlString) { - mPlugin->LoadHTMLString( htmlString ); + mPlugin->LoadHtmlString(htmlString); } void WebEngine::Reload() @@ -213,6 +259,61 @@ 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); +} + +Dali::Vector2 WebEngine::GetScrollPosition() const +{ + return mPlugin->GetScrollPosition(); +} + +Dali::Vector2 WebEngine::GetScrollSize() const +{ + return mPlugin->GetScrollSize(); +} + +Dali::Vector2 WebEngine::GetContentSize() const +{ + return mPlugin->GetContentSize(); +} + +void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback) +{ + mPlugin->RegisterJavaScriptAlertCallback(callback); +} + +void WebEngine::JavaScriptAlertReply() +{ + mPlugin->JavaScriptAlertReply(); +} + +void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback) +{ + mPlugin->RegisterJavaScriptAlertCallback(callback); +} + +void WebEngine::JavaScriptConfirmReply(bool confirmed) +{ + mPlugin->JavaScriptConfirmReply(confirmed); +} + +void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback) +{ + mPlugin->RegisterJavaScriptPromptCallback(callback); +} + +void WebEngine::JavaScriptPromptReply(const std::string& result) +{ + mPlugin->JavaScriptPromptReply(result); +} + bool WebEngine::CanGoForward() { return mPlugin->CanGoForward(); @@ -233,14 +334,19 @@ void WebEngine::GoBack() mPlugin->GoBack(); } -void WebEngine::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) +void WebEngine::EvaluateJavaScript(const std::string& script, std::function resultHandler) +{ + mPlugin->EvaluateJavaScript(script, resultHandler); +} + +void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler) { - mPlugin->EvaluateJavaScript( script, resultHandler ); + mPlugin->AddJavaScriptMessageHandler(exposedObjectName, handler); } -void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler ) +void WebEngine::ClearAllTilesResources() { - mPlugin->AddJavaScriptMessageHandler( exposedObjectName, handler ); + mPlugin->ClearAllTilesResources(); } void WebEngine::ClearHistory() @@ -248,117 +354,121 @@ void WebEngine::ClearHistory() mPlugin->ClearHistory(); } -void WebEngine::ClearCache() +void WebEngine::SetSize(int width, int height) { - mPlugin->ClearCache(); + mPlugin->SetSize(width, height); } -void WebEngine::ClearCookies() +void WebEngine::EnableMouseEvents(bool enabled) { - mPlugin->ClearCookies(); + mPlugin->EnableMouseEvents(enabled); } -Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const +void WebEngine::EnableKeyEvents(bool enabled) { - return mPlugin->GetCacheModel(); + mPlugin->EnableKeyEvents(enabled); } -void WebEngine::SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ) +bool WebEngine::SendTouchEvent(const Dali::TouchEvent& touch) { - mPlugin->SetCacheModel( cacheModel ); + return mPlugin->SendTouchEvent(touch); } -Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const +bool WebEngine::SendKeyEvent(const Dali::KeyEvent& event) { - return mPlugin->GetCookieAcceptPolicy(); + return mPlugin->SendKeyEvent(event); } -void WebEngine::SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ) +void WebEngine::SetFocus(bool focused) { - mPlugin->SetCookieAcceptPolicy( policy ); + mPlugin->SetFocus(focused); } -const std::string& WebEngine::GetUserAgent() const +void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color) { - return mPlugin->GetUserAgent(); + mPlugin->SetDocumentBackgroundColor(color); } -void WebEngine::SetUserAgent( const std::string& userAgent ) +void WebEngine::ClearTilesWhenHidden(bool cleared) { - mPlugin->SetUserAgent( userAgent ); + mPlugin->ClearTilesWhenHidden(cleared); } -bool WebEngine::IsJavaScriptEnabled() const +void WebEngine::SetTileCoverAreaMultiplier(float multiplier) { - return mPlugin->IsJavaScriptEnabled(); + mPlugin->SetTileCoverAreaMultiplier(multiplier); } -void WebEngine::EnableJavaScript( bool enabled ) +void WebEngine::EnableCursorByClient(bool enabled) { - mPlugin->EnableJavaScript( enabled ); + mPlugin->EnableCursorByClient(enabled); } -bool WebEngine::AreImagesAutomaticallyLoaded() const +std::string WebEngine::GetSelectedText() const { - return mPlugin->AreImagesAutomaticallyLoaded(); + return mPlugin->GetSelectedText(); } -void WebEngine::LoadImagesAutomatically( bool automatic ) +void WebEngine::UpdateDisplayArea(Dali::Rect displayArea) { - mPlugin->LoadImagesAutomatically( automatic ); + mPlugin->UpdateDisplayArea(displayArea); } -const std::string& WebEngine::GetDefaultTextEncodingName() const +void WebEngine::EnableVideoHole(bool enabled) { - return mPlugin->GetDefaultTextEncodingName(); + mPlugin->EnableVideoHole(enabled); } -void WebEngine::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) +bool WebEngine::SendHoverEvent( const Dali::HoverEvent& event ) { - mPlugin->SetDefaultTextEncodingName( defaultTextEncodingName ); + return mPlugin->SendHoverEvent( event ); } -int WebEngine::GetDefaultFontSize() const +bool WebEngine::SendWheelEvent( const Dali::WheelEvent& event ) { - return mPlugin->GetDefaultFontSize(); + return mPlugin->SendWheelEvent( event ); } -void WebEngine::SetDefaultFontSize( int defaultFontSize ) +Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal() { - mPlugin->SetDefaultFontSize( defaultFontSize ); + return mPlugin->PageLoadStartedSignal(); } -void WebEngine::SetSize( int width, int height ) +Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal() { - mPlugin->SetSize( width, height ); + return mPlugin->PageLoadInProgressSignal(); } -bool WebEngine::SendTouchEvent( const Dali::TouchEvent& touch ) +Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal() { - return mPlugin->SendTouchEvent( touch ); + return mPlugin->PageLoadFinishedSignal(); } -bool WebEngine::SendKeyEvent( const Dali::KeyEvent& event ) +Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal() { - return mPlugin->SendKeyEvent( event ); + return mPlugin->PageLoadErrorSignal(); } -Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal() +Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal() { - return mPlugin->PageLoadStartedSignal(); + return mPlugin->ScrollEdgeReachedSignal(); } -Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal() +Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal() { - return mPlugin->PageLoadFinishedSignal(); + return mPlugin->UrlChangedSignal(); } -Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal() +Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal() { - return mPlugin->PageLoadErrorSignal(); + return mPlugin->FormRepostDecisionSignal(); } -} // namespace Adaptor; -} // namespace Internal; -} // namespace Dali; +Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal() +{ + return mPlugin->FrameRenderedSignal(); +} +} // namespace Adaptor +} // namespace Internal +} // namespace Dali