1 #ifndef DALI_WEB_ENGINE_IMPL_H
2 #define DALI_WEB_ENGINE_IMPL_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/base-object.h>
25 #include <dali/devel-api/adaptor-framework/web-engine.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
31 // forward declaration
32 class WebEngineBackForwardList;
33 class WebEngineContext;
34 class WebEngineCookieManager;
35 class WebEngineSettings;
45 typedef IntrusivePtr< WebEngine > WebEnginePtr;
48 * @brief WebEngine class is used for Web.
50 class WebEngine : public Dali::BaseObject
55 * @brief Creates a new WebEngine handle
57 * @return WebEngine pointer
59 static WebEnginePtr New();
62 * @copydoc Dali::WebEngine::Create()
64 void Create( int width, int height, const std::string& locale, const std::string& timezoneId );
67 * @copydoc Dali::WebEngine::Destroy()
72 * @copydoc Dali::WebEngine::GetNativeImageSource()
74 Dali::NativeImageInterfacePtr GetNativeImageSource();
77 * @copydoc Dali::WebEngine::GetSettings()
79 Dali::WebEngineSettings& GetSettings() const;
82 * @copydoc Dali::WebEngine::GetContext()
84 Dali::WebEngineContext& GetContext() const;
87 * @copydoc Dali::WebEngine::GetCookieManager()
89 Dali::WebEngineCookieManager& GetCookieManager() const;
92 * @copydoc Dali::WebEngine::GetBackForwardList()
94 Dali::WebEngineBackForwardList& GetBackForwardList() const;
97 * @copydoc Dali::WebEngine::LoadUrl()
99 void LoadUrl( const std::string& url );
102 * @copydoc Dali::WebEngine::GetUrl()
104 const std::string& GetUrl();
107 * @copydoc Dali::WebEngine::LoadHtmlString()
109 void LoadHtmlString( const std::string& htmlString );
112 * @copydoc Dali::WebEngine::Reload()
117 * @copydoc Dali::WebEngine::StopLoading()
122 * @copydoc Dali::WebEngine::Suspend()
127 * @copydoc Dali::WebEngine::Resume()
132 * @copydoc Dali::WebEngine::ScrollBy()
134 void ScrollBy( int deltaX, int deltaY );
137 * @copydoc Dali::WebEngine::SetScrollPosition()
139 void SetScrollPosition( int x, int y );
142 * @copydoc Dali::WebEngine::GetScrollPosition()
144 void GetScrollPosition( int& x, int& y ) const;
147 * @copydoc Dali::WebEngine::GetScrollSize()
149 void GetScrollSize( int& width, int& height ) const;
152 * @copydoc Dali::WebEngine::GetContentSize()
154 void GetContentSize( int& width, int& height ) const;
157 * @copydoc Dali::WebEngine::CanGoForward()
162 * @copydoc Dali::WebEngine::GoForward()
167 * @copydoc Dali::WebEngine::CanGoBack()
172 * @copydoc Dali::WebEngine::GoBack()
177 * @copydoc Dali::WebEngine::EvaluateJavaScript()
179 void EvaluateJavaScript( const std::string& script, std::function< void(const std::string&) > resultHandler );
182 * @copydoc Dali::WebEngine::AddJavaScriptMessageHandler()
184 void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler );
187 * @copydoc Dali::WebEngine::GetUserAgent()
189 const std::string& GetUserAgent() const;
192 * @copydoc Dali::WebEngine::SetUserAgent()
194 void SetUserAgent( const std::string& userAgent );
197 * @copydoc Dali::WebEngine::ClearHistory()
202 * @copydoc Dali::WebEngine::SetSize()
204 void SetSize( int width, int height );
207 * @copydoc Dali::WebEngine::SendTouchEvent()
209 bool SendTouchEvent( const Dali::TouchEvent& touch );
212 * @copydoc Dali::WebEngine::SendKeyEvent()
214 bool SendKeyEvent( const Dali::KeyEvent& event );
217 * @copydoc Dali::WebEngine::SetFocus()
219 void SetFocus( bool focused );
222 * @copydoc Dali::WebEngine::PageLoadStartedSignal()
224 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal();
227 * @copydoc Dali::WebEngine::PageLoadFinishedSignal()
229 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal();
232 * @copydoc Dali::WebEngine::PageLoadErrorSignal()
234 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal();
237 * @copydoc Dali::WebEngine::ScrollEdgeReachedSignal()
239 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
244 * @brief Constructor.
251 virtual ~WebEngine();
253 // Undefined copy constructor
254 WebEngine( const WebEngine& WebEngine );
256 // Undefined assignment operator
257 WebEngine& operator=( const WebEngine& WebEngine );
260 * @brief Initializes member data.
262 * @return Whether the initialization succeed or not.
267 * @brief Initializes library handle by loading web engine plugin.
269 * @return Whether the initialization succeed or not.
271 bool InitializePluginHandle();
275 typedef Dali::WebEnginePlugin* (*CreateWebEngineFunction)();
276 typedef void (*DestroyWebEngineFunction)( Dali::WebEnginePlugin* plugin );
278 Dali::WebEnginePlugin* mPlugin; ///< WebEnginePlugin instance
279 void* mHandle; ///< Handle for the loaded library
280 CreateWebEngineFunction mCreateWebEnginePtr; ///< Function to create plugin instance
281 DestroyWebEngineFunction mDestroyWebEnginePtr; ///< Function to destroy plugin instance
284 } // namespace Adaptor
285 } // namespace Internal
287 inline static Internal::Adaptor::WebEngine& GetImplementation( Dali::WebEngine& webEngine )
289 DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
291 BaseObject& handle = webEngine.GetBaseObject();
293 return static_cast< Internal::Adaptor::WebEngine& >( handle );
296 inline static const Internal::Adaptor::WebEngine& GetImplementation( const Dali::WebEngine& webEngine )
298 DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
300 const BaseObject& handle = webEngine.GetBaseObject();
302 return static_cast< const Internal::Adaptor::WebEngine& >( handle );