1 #ifndef DALI_WEB_ENGINE_PLUGIN_H
2 #define DALI_WEB_ENGINE_PLUGIN_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/images/native-image-interface.h>
23 #include <dali/public-api/signals/dali-signal.h>
32 * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
33 * A concrete implementation must be created for each platform and provided as dynamic library.
39 * @brief WebEngine signal type related with page loading.
41 typedef Signal<void(const std::string&)> WebEnginePageLoadSignalType;
44 * @brief WebView signal type related with page loading error.
46 typedef Signal<void(const std::string&, int)> WebEnginePageLoadErrorSignalType;
49 * @brief Enumeration for cache model options.
54 * @brief Use the smallest cache capacity.
59 * @brief Use the bigger cache capacity than DocumentBrowser.
64 * @brief Use the biggest cache capacity.
70 * @brief Enumeration for the cookies accept policies.
72 enum class CookieAcceptPolicy
75 * @brief Accepts every cookie sent from any page.
80 * @brief Rejects all the cookies.
85 * @brief Accepts only cookies set by the main document that is loaded.
100 virtual ~WebEnginePlugin()
105 * @brief Creates WebEngine instance.
107 * @param [in] width The width of Web
108 * @param [in] height The height of Web
109 * @param [in] locale The locale of Web
110 * @param [in] timezoneId The timezoneID of Web
112 virtual void Create(int width, int height, const std::string& locale, const std::string& timezoneId) = 0;
115 * @brief Destroys WebEngine instance.
117 virtual void Destroy() = 0;
120 * @brief Loads a web page based on a given URL.
122 * @param [in] url The URL of the resource to load
124 virtual void LoadUrl(const std::string& url) = 0;
127 * @brief Gets image to render.
129 virtual NativeImageInterfacePtr GetNativeImageSource() = 0;
132 * @brief Returns the URL of the Web.
134 * @return Url of string type
136 virtual const std::string& GetUrl() = 0;
139 * @brief Loads a given string as web contents.
141 * @param [in] htmlString The string to use as the contents of the web page
143 virtual void LoadHTMLString(const std::string& htmlString) = 0;
146 * @brief Reloads the Web.
148 virtual void Reload() = 0;
151 * @brief Stops loading web contents on the current page.
153 virtual void StopLoading() = 0;
156 * @brief Suspends the operation associated with the view.
158 virtual void Suspend() = 0;
161 * @brief Resumes the operation associated with the view object after calling Suspend().
163 virtual void Resume() = 0;
166 * @brief Returns whether forward is possible.
168 * @return True if forward is possible, false otherwise
170 virtual bool CanGoForward() = 0;
173 * @brief Goes to forward.
175 virtual void GoForward() = 0;
178 * @brief Returns whether backward is possible.
180 * @return True if backward is possible, false otherwise
182 virtual bool CanGoBack() = 0;
185 * @brief Goes to back.
187 virtual void GoBack() = 0;
190 * @brief Evaluates JavaScript code represented as a string.
192 * @param[in] script The JavaScript code
193 * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result.
195 virtual void EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler) = 0;
198 * @brief Add a message handler into JavaScript.
200 * @param[in] exposedObjectName The name of exposed object
201 * @param[in] handler The callback function
203 virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler) = 0;
206 * @brief Clears the history of Web.
208 virtual void ClearHistory() = 0;
211 * @brief Clears the cache of Web.
213 virtual void ClearCache() = 0;
216 * @brief Clears all the cookies of Web.
218 virtual void ClearCookies() = 0;
221 * @brief Get cache model option. The default is DOCUMENT_VIEWER.
223 * @return The cache model option
225 virtual CacheModel GetCacheModel() const = 0;
228 * @brief Set cache model option. The default is DOCUMENT_VIEWER.
230 * @param[in] cacheModel The cache model option
232 virtual void SetCacheModel(CacheModel cacheModel) = 0;
235 * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY.
237 * @return The cookie acceptance policy
239 virtual CookieAcceptPolicy GetCookieAcceptPolicy() const = 0;
242 * @brief Sets the cookie acceptance policy. The default is NO_THIRD_PARTY.
244 * @param[in] policy The cookie acceptance policy
246 virtual void SetCookieAcceptPolicy(CookieAcceptPolicy policy) = 0;
249 * @brief Get user agent string.
251 * @return The string value of user agent
253 virtual const std::string& GetUserAgent() const = 0;
256 * @brief Set user agent string.
258 * @param[in] userAgent The string value of user agent
260 virtual void SetUserAgent(const std::string& userAgent) = 0;
263 * @brief Returns whether JavaScript can be executable. The default is true.
265 * @return true if JavaScript executing is enabled, false otherwise
267 virtual bool IsJavaScriptEnabled() const = 0;
270 * @brief Enables/disables JavaScript executing. The default is enabled.
272 * @param[in] enabled True if JavaScript executing is enabled, false otherwise
274 virtual void EnableJavaScript(bool enabled) = 0;
277 * @brief Returns whether images can be loaded automatically. The default is true.
279 * @return true if images are loaded automatically, false otherwise
281 virtual bool AreImagesAutomaticallyLoaded() const = 0;
284 * @brief Enables/disables auto loading of images. The default is enabled.
286 * @param[in] automatic True if images are loaded automatically, false otherwise
288 virtual void LoadImagesAutomatically(bool automatic) = 0;
291 * @brief Gets the default text encoding name (e.g. UTF-8).
293 * @return The default text encoding name
295 virtual const std::string& GetDefaultTextEncodingName() const = 0;
298 * @brief Sets the default text encoding name (e.g. UTF-8).
300 * @param[in] defaultTextEncodingName The default text encoding name
302 virtual void SetDefaultTextEncodingName(const std::string& defaultTextEncodingName) = 0;
305 * @brief Returns the default font size in pixel. The default value is 16.
307 * @return The default font size
309 virtual int GetDefaultFontSize() const = 0;
312 * @brief Sets the default font size in pixel. The default value is 16.
314 * @param[in] defaultFontSize A new default font size to set
316 virtual void SetDefaultFontSize(int defaultFontSize) = 0;
319 * @brief Sets size of Web Page.
321 virtual void SetSize(int width, int height) = 0;
324 * @brief Sends Touch Events.
326 virtual bool SendTouchEvent(const TouchEvent& touch) = 0;
329 * @brief Sends Key Events.
331 virtual bool SendKeyEvent(const KeyEvent& event) = 0;
334 * @brief Connects to this signal to be notified when page loading is started.
336 * @return A signal object to connect with.
338 virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0;
341 * @brief Connects to this signal to be notified when page loading is finished.
343 * @return A signal object to connect with.
345 virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0;
348 * @brief Connects to this signal to be notified when an error occurs in page loading.
350 * @return A signal object to connect with.
352 virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0;