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::Create()
69 void Create( int width, int height, int argc, char** argv );
72 * @copydoc Dali::WebEngine::Destroy()
77 * @copydoc Dali::WebEngine::GetNativeImageSource()
79 Dali::NativeImageInterfacePtr GetNativeImageSource();
82 * @copydoc Dali::WebEngine::GetSettings()
84 Dali::WebEngineSettings& GetSettings() const;
87 * @copydoc Dali::WebEngine::GetContext()
89 Dali::WebEngineContext& GetContext() const;
92 * @copydoc Dali::WebEngine::GetCookieManager()
94 Dali::WebEngineCookieManager& GetCookieManager() const;
97 * @copydoc Dali::WebEngine::GetBackForwardList()
99 Dali::WebEngineBackForwardList& GetBackForwardList() const;
102 * @copydoc Dali::WebEngine::LoadUrl()
104 void LoadUrl( const std::string& url );
107 * @copydoc Dali::WebEngine::GetTitle()
109 std::string GetTitle() const;
112 * @copydoc Dali::WebEngine::GetFavicon()
114 Dali::PixelData GetFavicon() const;
117 * @copydoc Dali::WebEngine::GetUrl()
119 const std::string& GetUrl();
122 * @copydoc Dali::WebEngine::GetUserAgent()
124 const std::string& GetUserAgent() const;
127 * @copydoc Dali::WebEngine::SetUserAgent()
129 void SetUserAgent( const std::string& userAgent );
132 * @copydoc Dali::WebEngine::LoadHtmlString()
134 void LoadHtmlString( const std::string& htmlString );
137 * @copydoc Dali::WebEngine::Reload()
142 * @copydoc Dali::WebEngine::StopLoading()
147 * @copydoc Dali::WebEngine::Suspend()
152 * @copydoc Dali::WebEngine::Resume()
157 * @copydoc Dali::WebEngine::ScrollBy()
159 void ScrollBy( int deltaX, int deltaY );
162 * @copydoc Dali::WebEngine::SetScrollPosition()
164 void SetScrollPosition( int x, int y );
167 * @copydoc Dali::WebEngine::GetScrollPosition()
169 void GetScrollPosition( int& x, int& y ) const;
172 * @copydoc Dali::WebEngine::GetScrollSize()
174 void GetScrollSize( int& width, int& height ) const;
177 * @copydoc Dali::WebEngine::GetContentSize()
179 void GetContentSize( int& width, int& height ) const;
182 * @copydoc Dali::WebEngine::CanGoForward()
187 * @copydoc Dali::WebEngine::GoForward()
192 * @copydoc Dali::WebEngine::CanGoBack()
197 * @copydoc Dali::WebEngine::GoBack()
202 * @copydoc Dali::WebEngine::EvaluateJavaScript()
204 void EvaluateJavaScript( const std::string& script, std::function< void(const std::string&) > resultHandler );
207 * @copydoc Dali::WebEngine::AddJavaScriptMessageHandler()
209 void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler );
212 * @copydoc Dali::WebEngine::ClearAllTilesResources()
214 void ClearAllTilesResources();
217 * @copydoc Dali::WebEngine::ClearHistory()
222 * @copydoc Dali::WebEngine::SetSize()
224 void SetSize( int width, int height );
227 * @copydoc Dali::WebEngine::SendTouchEvent()
229 bool SendTouchEvent( const Dali::TouchEvent& touch );
232 * @copydoc Dali::WebEngine::SendKeyEvent()
234 bool SendKeyEvent( const Dali::KeyEvent& event );
237 * @copydoc Dali::WebEngine::SetFocus()
239 void SetFocus( bool focused );
242 * @copydoc Dali::WebEngine::UpdateDisplayArea()
244 void UpdateDisplayArea( Dali::Rect< int > displayArea );
247 * @copydoc Dali::WebEngine::EnableVideoHole()
249 void EnableVideoHole( bool enabled );
252 * @copydoc Dali::WebEngine::PageLoadStartedSignal()
254 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal();
257 * @copydoc Dali::WebEngine::PageLoadFinishedSignal()
259 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal();
262 * @copydoc Dali::WebEngine::PageLoadErrorSignal()
264 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal();
267 * @copydoc Dali::WebEngine::ScrollEdgeReachedSignal()
269 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
274 * @brief Constructor.
281 virtual ~WebEngine();
283 // Undefined copy constructor
284 WebEngine( const WebEngine& WebEngine );
286 // Undefined assignment operator
287 WebEngine& operator=( const WebEngine& WebEngine );
290 * @brief Initializes member data.
292 * @return Whether the initialization succeed or not.
297 * @brief Initializes library handle by loading web engine plugin.
299 * @return Whether the initialization succeed or not.
301 bool InitializePluginHandle();
305 typedef Dali::WebEnginePlugin* (*CreateWebEngineFunction)();
306 typedef void (*DestroyWebEngineFunction)( Dali::WebEnginePlugin* plugin );
308 Dali::WebEnginePlugin* mPlugin; ///< WebEnginePlugin instance
309 void* mHandle; ///< Handle for the loaded library
310 CreateWebEngineFunction mCreateWebEnginePtr; ///< Function to create plugin instance
311 DestroyWebEngineFunction mDestroyWebEnginePtr; ///< Function to destroy plugin instance
314 } // namespace Adaptor
315 } // namespace Internal
317 inline static Internal::Adaptor::WebEngine& GetImplementation( Dali::WebEngine& webEngine )
319 DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
321 BaseObject& handle = webEngine.GetBaseObject();
323 return static_cast< Internal::Adaptor::WebEngine& >( handle );
326 inline static const Internal::Adaptor::WebEngine& GetImplementation( const Dali::WebEngine& webEngine )
328 DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
330 const BaseObject& handle = webEngine.GetBaseObject();
332 return static_cast< const Internal::Adaptor::WebEngine& >( handle );