1 #ifndef DALI_WEB_ENGINE_PLUGIN_H
2 #define DALI_WEB_ENGINE_PLUGIN_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/images/native-image-interface.h>
23 #include <dali/public-api/signals/dali-signal.h>
33 * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
34 * A concrete implementation must be created for each platform and provided as dynamic library.
41 * @brief WebEngine signal type related with page loading.
43 typedef Signal< void( const std::string& ) > WebEnginePageLoadSignalType;
46 * @brief WebView signal type related with page loading error.
48 typedef Signal< void( const std::string&, int ) > WebEnginePageLoadErrorSignalType;
51 * @brief Enumeration for cache model options.
56 * @brief Use the smallest cache capacity.
61 * @brief Use the bigger cache capacity than DocumentBrowser.
66 * @brief Use the biggest cache capacity.
72 * @brief Enumeration for the cookies accept policies.
74 enum class CookieAcceptPolicy
77 * @brief Accepts every cookie sent from any page.
82 * @brief Rejects all the cookies.
87 * @brief Accepts only cookies set by the main document that is loaded.
102 virtual ~WebEnginePlugin()
107 * @brief Creates WebEngine instance.
109 * @param [in] width The width of Web
110 * @param [in] height The height of Web
111 * @param [in] locale The locale of Web
112 * @param [in] timezoneId The timezoneID of Web
114 virtual void Create( int width, int height, const std::string& locale, const std::string& timezoneId ) = 0;
117 * @brief Destroys WebEngine instance.
119 virtual void Destroy() = 0;
122 * @brief Loads a web page based on a given URL.
124 * @param [in] url The URL of the resource to load
126 virtual void LoadUrl( const std::string& url ) = 0;
129 * @brief Gets image to render.
131 virtual NativeImageInterfacePtr GetNativeImageSource() = 0;
134 * @brief Returns the URL of the Web.
136 * @return Url of string type
138 virtual const std::string& GetUrl() = 0;
141 * @brief Loads a given string as web contents.
143 * @param [in] htmlString The string to use as the contents of the web page
145 virtual void LoadHTMLString( const std::string& htmlString ) = 0;
148 * @brief Reloads the Web.
150 virtual void Reload() = 0;
153 * @brief Stops loading web contents on the current page.
155 virtual void StopLoading() = 0;
158 * @brief Suspends the operation associated with the view.
160 virtual void Suspend() = 0;
163 * @brief Resumes the operation associated with the view object after calling Suspend().
165 virtual void Resume() = 0;
168 * @brief Returns whether forward is possible.
170 * @return True if forward is possible, false otherwise
172 virtual bool CanGoForward() = 0;
175 * @brief Goes to forward.
177 virtual void GoForward() = 0;
180 * @brief Returns whether backward is possible.
182 * @return True if backward is possible, false otherwise
184 virtual bool CanGoBack() = 0;
187 * @brief Goes to back.
189 virtual void GoBack() = 0;
192 * @brief Evaluates JavaScript code represented as a string.
194 * @param[in] script The JavaScript code
195 * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result.
197 virtual void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) = 0;
200 * @brief Add a message handler into JavaScript.
202 * @param[in] exposedObjectName The name of exposed object
203 * @param[in] handler The callback function
205 virtual void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ) = 0;
208 * @brief Clears the history of Web.
210 virtual void ClearHistory() = 0;
213 * @brief Clears the cache of Web.
215 virtual void ClearCache() = 0;
218 * @brief Clears all the cookies of Web.
220 virtual void ClearCookies() = 0;
223 * @brief Get cache model option. The default is DOCUMENT_VIEWER.
225 * @return The cache model option
227 virtual CacheModel GetCacheModel() const = 0;
230 * @brief Set cache model option. The default is DOCUMENT_VIEWER.
232 * @param[in] cacheModel The cache model option
234 virtual void SetCacheModel( CacheModel cacheModel ) = 0;
237 * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY.
239 * @return The cookie acceptance policy
241 virtual CookieAcceptPolicy GetCookieAcceptPolicy() const = 0;
244 * @brief Sets the cookie acceptance policy. The default is NO_THIRD_PARTY.
246 * @param[in] policy The cookie acceptance policy
248 virtual void SetCookieAcceptPolicy( CookieAcceptPolicy policy ) = 0;
251 * @brief Get user agent string.
253 * @return The string value of user agent
255 virtual const std::string& GetUserAgent() const = 0;
258 * @brief Set user agent string.
260 * @param[in] userAgent The string value of user agent
262 virtual void SetUserAgent( const std::string& userAgent ) = 0;
265 * @brief Returns whether JavaScript can be executable. The default is true.
267 * @return true if JavaScript executing is enabled, false otherwise
269 virtual bool IsJavaScriptEnabled() const = 0;
272 * @brief Enables/disables JavaScript executing. The default is enabled.
274 * @param[in] enabled True if JavaScript executing is enabled, false otherwise
276 virtual void EnableJavaScript( bool enabled ) = 0;
279 * @brief Returns whether images can be loaded automatically. The default is true.
281 * @return true if images are loaded automatically, false otherwise
283 virtual bool AreImagesAutomaticallyLoaded() const = 0;
286 * @brief Enables/disables auto loading of images. The default is enabled.
288 * @param[in] automatic True if images are loaded automatically, false otherwise
290 virtual void LoadImagesAutomatically( bool automatic ) = 0;
293 * @brief Gets the default text encoding name (e.g. UTF-8).
295 * @return The default text encoding name
297 virtual const std::string& GetDefaultTextEncodingName() const = 0;
300 * @brief Sets the default text encoding name (e.g. UTF-8).
302 * @param[in] defaultTextEncodingName The default text encoding name
304 virtual void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) = 0;
307 * @brief Returns the default font size in pixel. The default value is 16.
309 * @return The default font size
311 virtual int GetDefaultFontSize() const = 0;
314 * @brief Sets the default font size in pixel. The default value is 16.
316 * @param[in] defaultFontSize A new default font size to set
318 virtual void SetDefaultFontSize( int defaultFontSize ) = 0;
321 * @brief Sets size of Web Page.
323 virtual void SetSize( int width, int height ) = 0;
326 * @brief Sends Touch Events.
328 virtual bool SendTouchEvent( const TouchData& touch ) = 0;
331 * @brief Sends Key Events.
333 virtual bool SendKeyEvent( const KeyEvent& event ) = 0;
336 * @brief Connects to this signal to be notified when page loading is started.
338 * @return A signal object to connect with.
340 virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0;
343 * @brief Connects to this signal to be notified when page loading is finished.
345 * @return A signal object to connect with.
347 virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0;
350 * @brief Connects to this signal to be notified when an error occurs in page loading.
352 * @return A signal object to connect with.
354 virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0;