1 #ifndef DALI_WEB_ENGINE_IMPL_H
2 #define DALI_WEB_ENGINE_IMPL_H
5 * Copyright (c) 2018 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>
39 typedef IntrusivePtr< WebEngine > WebEnginePtr;
42 * @brief WebEngine class is used for Web.
44 class WebEngine : public Dali::BaseObject
49 * @brief Creates a new WebEngine handle
51 * @return WebEngine pointer
53 static WebEnginePtr New();
56 * @copydoc Dali::WebEngine::Create()
58 void Create( int width, int height, const std::string& locale, const std::string& timezoneId );
61 * @copydoc Dali::WebEngine::Destroy()
66 * @copydoc Dali::WebEngine::GetNativeImageSource()
68 Dali::NativeImageInterfacePtr GetNativeImageSource();
71 * @copydoc Dali::WebEngine::LoadUrl()
73 void LoadUrl( const std::string& url );
76 * @copydoc Dali::WebEngine::GetUrl()
78 const std::string& GetUrl();
81 * @copydoc Dali::WebEngine::LoadHTMLString()
83 void LoadHTMLString( const std::string& htmlString );
86 * @copydoc Dali::WebEngine::Reload()
91 * @copydoc Dali::WebEngine::StopLoading()
96 * @copydoc Dali::WebEngine::CanGoForward()
101 * @copydoc Dali::WebEngine::GoForward()
106 * @copydoc Dali::WebEngine::CanGoBack()
111 * @copydoc Dali::WebEngine::GoBack()
116 * @copydoc Dali::WebEngine::EvaluateJavaScript()
118 void EvaluateJavaScript( const std::string& script );
121 * @copydoc Dali::WebEngine::AddJavaScriptMessageHandler()
123 void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler );
126 * @copydoc Dali::WebEngine::ClearHistory()
131 * @copydoc Dali::WebEngine::ClearCache()
136 * @copydoc Dali::WebEngine::SetSize()
138 void SetSize( int width, int height );
141 * @copydoc Dali::WebEngine::SendTouchEvent()
143 bool SendTouchEvent( const Dali::TouchData& touch );
146 * @copydoc Dali::WebEngine::SendKeyEvent()
148 bool SendKeyEvent( const Dali::KeyEvent& event );
151 * @copydoc Dali::WebEngine::PageLoadStartedSignal()
153 Dali::WebEnginePlugin::WebEngineSignalType& PageLoadStartedSignal();
156 * @copydoc Dali::WebEngine::PageLoadFinishedSignal()
158 Dali::WebEnginePlugin::WebEngineSignalType& PageLoadFinishedSignal();
163 * @brief Constructor.
170 virtual ~WebEngine();
172 // Undefined copy constructor
173 WebEngine( const WebEngine& WebEngine );
175 // Undefined assignment operator
176 WebEngine& operator=( const WebEngine& WebEngine );
179 * @brief Initializes member data.
181 * @return Whether the initialization succeed or not.
186 * @brief Initializes library handle by loading web engine plugin.
188 * @return Whether the initialization succeed or not.
190 bool InitializePluginHandle();
194 Dali::WebEnginePlugin* mPlugin; ///< WebEnginePlugin instance
195 void* mHandle; ///< Handle for the loaded library
197 typedef Dali::WebEnginePlugin* (*CreateWebEngineFunction)();
198 typedef void (*DestroyWebEngineFunction)( Dali::WebEnginePlugin* plugin );
200 CreateWebEngineFunction mCreateWebEnginePtr;
201 DestroyWebEngineFunction mDestroyWebEnginePtr;
204 } // namespace Adaptor
205 } // namespace Internal
207 inline static Internal::Adaptor::WebEngine& GetImplementation( Dali::WebEngine& webEngine )
209 DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
211 BaseObject& handle = webEngine.GetBaseObject();
213 return static_cast< Internal::Adaptor::WebEngine& >( handle );
216 inline static const Internal::Adaptor::WebEngine& GetImplementation( const Dali::WebEngine& webEngine )
218 DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
220 const BaseObject& handle = webEngine.GetBaseObject();
222 return static_cast< const Internal::Adaptor::WebEngine& >( handle );