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>
30 class WebEngineBackForwardList;
31 class WebEngineContext;
32 class WebEngineCookieManager;
33 class WebEngineSettings;
36 * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
37 * A concrete implementation must be created for each platform and provided as dynamic library.
43 * @brief WebEngine signal type related with page loading.
45 typedef Signal<void(const std::string&)> WebEnginePageLoadSignalType;
48 * @brief WebView signal type related with page loading error.
50 typedef Signal<void(const std::string&, int)> WebEnginePageLoadErrorSignalType;
52 // forward declaration.
53 enum class ScrollEdge;
56 * @brief WebView signal type related with scroll edge reached.
58 typedef Signal< void( const ScrollEdge )> WebEngineScrollEdgeReachedSignalType;
61 * @brief Enumeration for the scroll edge.
65 LEFT, ///< Left edge reached.
66 RIGHT, ///< Right edge reached.
67 TOP, ///< Top edge reached.
68 BOTTOM, ///< Bottom edge reached.
74 WebEnginePlugin() = default;
79 virtual ~WebEnginePlugin() = default;
82 * @brief Creates WebEngine instance.
84 * @param [in] width The width of Web
85 * @param [in] height The height of Web
86 * @param [in] locale The locale of Web
87 * @param [in] timezoneId The timezoneID of Web
89 virtual void Create(int width, int height, const std::string& locale, const std::string& timezoneId) = 0;
92 * @brief Destroys WebEngine instance.
94 virtual void Destroy() = 0;
97 * @brief Get settings of WebEngine.
99 virtual WebEngineSettings& GetSettings() const = 0;
102 * @brief Get context of WebEngine.
104 virtual WebEngineContext& GetContext() const = 0;
107 * @brief Get cookie manager of WebEngine.
109 virtual WebEngineCookieManager& GetCookieManager() const = 0;
112 * @brief Get back-forward list of WebEngine.
114 virtual WebEngineBackForwardList& GetBackForwardList() const = 0;
117 * @brief Loads a web page based on a given URL.
119 * @param [in] url The URL of the resource to load
121 virtual void LoadUrl(const std::string& url) = 0;
124 * @brief Gets image to render.
126 virtual NativeImageInterfacePtr GetNativeImageSource() = 0;
129 * @brief Returns the URL of the Web.
131 * @return Url of string type
133 virtual const std::string& GetUrl() = 0;
136 * @brief Loads a given string as web contents.
138 * @param [in] htmlString The string to use as the contents of the web page
140 virtual void LoadHtmlString(const std::string& htmlString) = 0;
143 * @brief Reloads the Web.
145 virtual void Reload() = 0;
148 * @brief Stops loading web contents on the current page.
150 virtual void StopLoading() = 0;
153 * @brief Suspends the operation associated with the view.
155 virtual void Suspend() = 0;
158 * @brief Resumes the operation associated with the view object after calling Suspend().
160 virtual void Resume() = 0;
163 * @brief Scrolls the webpage of view by deltaX and deltaY.
165 virtual void ScrollBy( int deltaX, int deltaY ) = 0;
168 * @brief Scroll to the specified position of the given view.
170 virtual void SetScrollPosition( int x, int y ) = 0;
173 * @brief Gets the current scroll position of the given view.
175 virtual void GetScrollPosition( int& x, int& y ) const = 0;
178 * @brief Gets the possible scroll size of the given view.
180 virtual void GetScrollSize( int& width, int& height ) const = 0;
183 * @brief Gets the last known content's size.
185 virtual void GetContentSize( int& width, int& height ) const = 0;
188 * @brief Returns whether forward is possible.
190 * @return True if forward is possible, false otherwise
192 virtual bool CanGoForward() = 0;
195 * @brief Goes to forward.
197 virtual void GoForward() = 0;
200 * @brief Returns whether backward is possible.
202 * @return True if backward is possible, false otherwise
204 virtual bool CanGoBack() = 0;
207 * @brief Goes to back.
209 virtual void GoBack() = 0;
212 * @brief Evaluates JavaScript code represented as a string.
214 * @param[in] script The JavaScript code
215 * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result.
217 virtual void EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler) = 0;
220 * @brief Add a message handler into JavaScript.
222 * @param[in] exposedObjectName The name of exposed object
223 * @param[in] handler The callback function
225 virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler) = 0;
228 * @brief Clears the history of Web.
230 virtual void ClearHistory() = 0;
233 * @brief Get user agent string.
235 * @return The string value of user agent
237 virtual const std::string& GetUserAgent() const = 0;
240 * @brief Set user agent string.
242 * @param[in] userAgent The string value of user agent
244 virtual void SetUserAgent(const std::string& userAgent) = 0;
247 * @brief Sets size of Web Page.
249 virtual void SetSize(int width, int height) = 0;
252 * @brief Sends Touch Events.
254 virtual bool SendTouchEvent(const TouchEvent& touch) = 0;
257 * @brief Sends Key Events.
259 virtual bool SendKeyEvent(const KeyEvent& event) = 0;
264 virtual void SetFocus( bool focused ) = 0;
267 * @brief Connects to this signal to be notified when page loading is started.
269 * @return A signal object to connect with.
271 virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0;
274 * @brief Connects to this signal to be notified when page loading is finished.
276 * @return A signal object to connect with.
278 virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0;
281 * @brief Connects to this signal to be notified when an error occurs in page loading.
283 * @return A signal object to connect with.
285 virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0;
288 * @brief Connects to this signal to be notified when scroll edge is reached.
290 * @return A signal object to connect with.
292 virtual WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal() = 0;