1 #ifndef DALI_WEB_ENGINE_H
2 #define DALI_WEB_ENGINE_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-handle.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
26 #include <dali/public-api/dali-adaptor-common.h>
37 } // namespace Adaptor
39 } // namespace Internal
42 * @brief Proxy class to dynamically load, use and unload web engine plugin.
44 * The purpose of this class is to dynamically load the web engine plugin if and when its needed.
45 * So we don't slow down every application startup if they never need web engine.
47 class DALI_ADAPTOR_API WebEngine : public BaseHandle
62 * @brief Creates a new instance of a WebEngine.
64 static WebEngine New();
67 * @brief Copy constructor.
69 * @param[in] WebEngine WebEngine to copy. The copied WebEngine will point at the same implementation
71 WebEngine( const WebEngine& WebEngine );
74 * @brief Assignment operator.
76 * @param[in] WebEngine The WebEngine to assign from.
77 * @return The updated WebEngine.
79 WebEngine& operator=( const WebEngine& WebEngine );
82 * @brief Downcast a handle to WebEngine handle.
84 * If handle points to a WebEngine the downcast produces valid
85 * handle. If not the returned handle is left uninitialized.
87 * @param[in] handle Handle to an object
88 * @return Handle to a WebEngine or an uninitialized handle
90 static WebEngine DownCast( BaseHandle handle );
93 * @brief Creates WebEngine instance.
95 * @param [in] width The width of Web
96 * @param [in] height The height of Web
97 * @param [in] locale The locale of Web
98 * @param [in] timezoneId The timezoneID of Web
100 void Create( int width, int height, const std::string& locale, const std::string& timezoneId );
103 * @brief Destroys WebEngine instance.
108 * @brief Gets native image source to render.
110 NativeImageInterfacePtr GetNativeImageSource();
113 * @brief Loads a web page based on a given URL.
115 * @param [in] url The URL of the resource to load
117 void LoadUrl( const std::string& url );
120 * @brief Gets the url.
122 const std::string& GetUrl();
125 * @brief Loads a given string as web contents.
127 * @param [in] htmlString The string to use as the contents of the web page
129 void LoadHTMLString( const std::string& htmlString );
132 * @brief Reloads the Web.
137 * @brief Stops loading web contents on the current page.
142 * @brief Returns whether forward is possible.
144 * @return True if forward is possible, false otherwise
149 * @brief Goes to forward.
154 * @brief Returns whether backward is possible.
156 * @return True if backward is possible, false otherwise
161 * @brief Goes to back.
166 * @brief Evaluates JavaScript code represented as a string.
168 * @param[in] script The JavaScript code
170 void EvaluateJavaScript( const std::string& script );
173 * @brief Add a message handler into JavaScript.
175 * @param[in] exposedObjectName The name of exposed object
176 * @param[in] handler The callback function
178 void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler );
181 * @brief Clears the history of Web.
186 * @brief Clears the cache of Web.
191 * @brief Sets the size of Web Pages.
193 void SetSize( int width, int height );
196 * @brief Sends Touch Events.
198 bool SendTouchEvent( const TouchData& touch );
201 * @brief Sends key Events.
203 bool SendKeyEvent( const KeyEvent& event );
206 * @brief Connects to this signal to be notified when page loading is started.
208 * @return A signal object to connect with.
210 Dali::WebEnginePlugin::WebEngineSignalType& PageLoadStartedSignal();
213 * @brief Connects to this signal to be notified when page loading is finished.
215 * @return A signal object to connect with.
217 Dali::WebEnginePlugin::WebEngineSignalType& PageLoadFinishedSignal();
219 private: // Not intended for application developers
222 * @brief Internal constructor
224 explicit DALI_INTERNAL WebEngine( Internal::Adaptor::WebEngine* internal );
229 #endif // DALI_WEB_ENGINE_H