1 #ifndef DALI_WEB_ENGINE_PLUGIN_H
2 #define DALI_WEB_ENGINE_PLUGIN_H
5 * Copyright (c) 2021 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/math/rect.h>
24 #include <dali/public-api/signals/dali-signal.h>
32 class WebEngineBackForwardList;
33 class WebEngineContext;
34 class WebEngineCookieManager;
35 class WebEngineSettings;
38 * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
39 * A concrete implementation must be created for each platform and provided as dynamic library.
45 * @brief WebEngine signal type related with page loading.
47 using WebEnginePageLoadSignalType = Signal<void(const std::string&)>;
50 * @brief WebView signal type related with page loading error.
52 using WebEnginePageLoadErrorSignalType = Signal<void(const std::string&, int)>;
54 // forward declaration.
55 enum class ScrollEdge;
58 * @brief WebView signal type related with scroll edge reached.
60 using WebEngineScrollEdgeReachedSignalType = Signal<void(const ScrollEdge)>;
63 * @brief Enumeration for the scroll edge.
67 LEFT, ///< Left edge reached.
68 RIGHT, ///< Right edge reached.
69 TOP, ///< Top edge reached.
70 BOTTOM, ///< Bottom edge reached.
76 WebEnginePlugin() = default;
81 virtual ~WebEnginePlugin() = default;
84 * @brief Creates WebEngine instance.
86 * @param [in] width The width of Web
87 * @param [in] height The height of Web
88 * @param [in] locale The locale of Web
89 * @param [in] timezoneId The timezoneID of Web
91 virtual void Create(int width, int height, const std::string& locale, const std::string& timezoneId) = 0;
94 * @brief Creates WebEngine instance.
96 * @param [in] width The width of Web
97 * @param [in] height The height of Web
98 * @param [in] argc The count of application arguments
99 * @param [in] argv The string array of application arguments
101 virtual void Create(int width, int height, int argc, char** argv) = 0;
104 * @brief Destroys WebEngine instance.
106 virtual void Destroy() = 0;
109 * @brief Get settings of WebEngine.
111 virtual WebEngineSettings& GetSettings() const = 0;
114 * @brief Get context of WebEngine.
116 virtual WebEngineContext& GetContext() const = 0;
119 * @brief Get cookie manager of WebEngine.
121 virtual WebEngineCookieManager& GetCookieManager() const = 0;
124 * @brief Get back-forward list of WebEngine.
126 virtual WebEngineBackForwardList& GetBackForwardList() const = 0;
129 * @brief Loads a web page based on a given URL.
131 * @param [in] url The URL of the resource to load
133 virtual void LoadUrl(const std::string& url) = 0;
136 * @brief Returns the title of the Web.
138 * @return The title of web page
140 virtual std::string GetTitle() const = 0;
143 * @brief Returns the Favicon of the Web.
145 * @return Favicon of Dali::PixelData& type
147 virtual Dali::PixelData GetFavicon() const = 0;
150 * @brief Gets image to render.
152 virtual NativeImageInterfacePtr GetNativeImageSource() = 0;
155 * @brief Returns the URL of the Web.
157 * @return Url of string type
159 virtual const std::string& GetUrl() = 0;
162 * @brief Loads a given string as web contents.
164 * @param [in] htmlString The string to use as the contents of the web page
166 virtual void LoadHtmlString(const std::string& htmlString) = 0;
169 * @brief Reloads the Web.
171 virtual void Reload() = 0;
174 * @brief Stops loading web contents on the current page.
176 virtual void StopLoading() = 0;
179 * @brief Suspends the operation associated with the view.
181 virtual void Suspend() = 0;
184 * @brief Resumes the operation associated with the view object after calling Suspend().
186 virtual void Resume() = 0;
189 * @brief Scrolls the webpage of view by deltaX and deltaY.
191 virtual void ScrollBy(int deltaX, int deltaY) = 0;
194 * @brief Scroll to the specified position of the given view.
196 virtual void SetScrollPosition(int x, int y) = 0;
199 * @brief Gets the current scroll position of the given view.
201 virtual Dali::Vector2 GetScrollPosition() const = 0;
204 * @brief Gets the possible scroll size of the given view.
206 virtual Dali::Vector2 GetScrollSize() const = 0;
209 * @brief Gets the last known content's size.
211 virtual Dali::Vector2 GetContentSize() const = 0;
214 * @brief Returns whether forward is possible.
216 * @return True if forward is possible, false otherwise
218 virtual bool CanGoForward() = 0;
221 * @brief Goes to forward.
223 virtual void GoForward() = 0;
226 * @brief Returns whether backward is possible.
228 * @return True if backward is possible, false otherwise
230 virtual bool CanGoBack() = 0;
233 * @brief Goes to back.
235 virtual void GoBack() = 0;
238 * @brief Evaluates JavaScript code represented as a string.
240 * @param[in] script The JavaScript code
241 * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result.
243 virtual void EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler) = 0;
246 * @brief Add a message handler into JavaScript.
248 * @param[in] exposedObjectName The name of exposed object
249 * @param[in] handler The callback function
251 virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler) = 0;
254 * @brief Clears all tiles resources of Web.
256 virtual void ClearAllTilesResources() = 0;
259 * @brief Clears the history of Web.
261 virtual void ClearHistory() = 0;
264 * @brief Get user agent string.
266 * @return The string value of user agent
268 virtual const std::string& GetUserAgent() const = 0;
271 * @brief Set user agent string.
273 * @param[in] userAgent The string value of user agent
275 virtual void SetUserAgent(const std::string& userAgent) = 0;
278 * @brief Sets size of Web Page.
280 virtual void SetSize(int width, int height) = 0;
283 * @brief Sends Touch Events.
285 virtual bool SendTouchEvent(const TouchEvent& touch) = 0;
288 * @brief Sends Key Events.
290 virtual bool SendKeyEvent(const KeyEvent& event) = 0;
295 virtual void SetFocus(bool focused) = 0;
298 * @brief Update display area.
299 * @param[in] displayArea The display area need be updated.
301 virtual void UpdateDisplayArea(Dali::Rect<int> displayArea) = 0;
304 * @brief Enable video hole.
305 * @param[in] enabled True if enabled, false othewise.
307 virtual void EnableVideoHole(bool enabled) = 0;
310 * @brief Connects to this signal to be notified when page loading is started.
312 * @return A signal object to connect with.
314 virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0;
317 * @brief Connects to this signal to be notified when page loading is finished.
319 * @return A signal object to connect with.
321 virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0;
324 * @brief Connects to this signal to be notified when an error occurs in page loading.
326 * @return A signal object to connect with.
328 virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0;
331 * @brief Connects to this signal to be notified when scroll edge is reached.
333 * @return A signal object to connect with.
335 virtual WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal() = 0;