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>
31 class WebEngineBackForwardList;
32 class WebEngineContext;
33 class WebEngineCookieManager;
34 class WebEngineSettings;
37 * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
38 * A concrete implementation must be created for each platform and provided as dynamic library.
44 * @brief WebEngine signal type related with page loading.
46 using WebEnginePageLoadSignalType = Signal< void( const std::string& ) >;
49 * @brief WebView signal type related with page loading error.
51 using WebEnginePageLoadErrorSignalType = Signal< void( const std::string&, int ) >;
53 // forward declaration.
54 enum class ScrollEdge;
57 * @brief WebView signal type related with scroll edge reached.
59 using WebEngineScrollEdgeReachedSignalType = Signal< void( const ScrollEdge ) >;
62 * @brief Enumeration for the scroll edge.
66 LEFT, ///< Left edge reached.
67 RIGHT, ///< Right edge reached.
68 TOP, ///< Top edge reached.
69 BOTTOM, ///< Bottom edge reached.
75 WebEnginePlugin() = default;
80 virtual ~WebEnginePlugin() = default;
83 * @brief Creates WebEngine instance.
85 * @param [in] width The width of Web
86 * @param [in] height The height of Web
87 * @param [in] locale The locale of Web
88 * @param [in] timezoneId The timezoneID of Web
90 virtual void Create(int width, int height, const std::string& locale, const std::string& timezoneId) = 0;
93 * @brief Creates WebEngine instance.
95 * @param [in] width The width of Web
96 * @param [in] height The height of Web
97 * @param [in] argc The count of application arguments
98 * @param [in] argv The string array of application arguments
100 virtual void Create( int width, int height, int argc, char** argv ) = 0;
103 * @brief Destroys WebEngine instance.
105 virtual void Destroy() = 0;
108 * @brief Get settings of WebEngine.
110 virtual WebEngineSettings& GetSettings() const = 0;
113 * @brief Get context of WebEngine.
115 virtual WebEngineContext& GetContext() const = 0;
118 * @brief Get cookie manager of WebEngine.
120 virtual WebEngineCookieManager& GetCookieManager() const = 0;
123 * @brief Get back-forward list of WebEngine.
125 virtual WebEngineBackForwardList& GetBackForwardList() const = 0;
128 * @brief Loads a web page based on a given URL.
130 * @param [in] url The URL of the resource to load
132 virtual void LoadUrl(const std::string& url) = 0;
135 * @brief Returns the title of the Web.
137 * @return The title of web page
139 virtual std::string GetTitle() const = 0;
142 * @brief Returns the Favicon of the Web.
144 * @return Favicon of Dali::PixelData& type
146 virtual Dali::PixelData GetFavicon() const = 0;
149 * @brief Gets image to render.
151 virtual NativeImageInterfacePtr GetNativeImageSource() = 0;
154 * @brief Returns the URL of the Web.
156 * @return Url of string type
158 virtual const std::string& GetUrl() = 0;
161 * @brief Loads a given string as web contents.
163 * @param [in] htmlString The string to use as the contents of the web page
165 virtual void LoadHtmlString(const std::string& htmlString) = 0;
168 * @brief Reloads the Web.
170 virtual void Reload() = 0;
173 * @brief Stops loading web contents on the current page.
175 virtual void StopLoading() = 0;
178 * @brief Suspends the operation associated with the view.
180 virtual void Suspend() = 0;
183 * @brief Resumes the operation associated with the view object after calling Suspend().
185 virtual void Resume() = 0;
188 * @brief Scrolls the webpage of view by deltaX and deltaY.
190 virtual void ScrollBy( int deltaX, int deltaY ) = 0;
193 * @brief Scroll to the specified position of the given view.
195 virtual void SetScrollPosition( int x, int y ) = 0;
198 * @brief Gets the current scroll position of the given view.
200 virtual Dali::Vector2 GetScrollPosition() const = 0;
203 * @brief Gets the possible scroll size of the given view.
205 virtual Dali::Vector2 GetScrollSize() const = 0;
208 * @brief Gets the last known content's size.
210 virtual Dali::Vector2 GetContentSize() const = 0;
213 * @brief Returns whether forward is possible.
215 * @return True if forward is possible, false otherwise
217 virtual bool CanGoForward() = 0;
220 * @brief Goes to forward.
222 virtual void GoForward() = 0;
225 * @brief Returns whether backward is possible.
227 * @return True if backward is possible, false otherwise
229 virtual bool CanGoBack() = 0;
232 * @brief Goes to back.
234 virtual void GoBack() = 0;
237 * @brief Evaluates JavaScript code represented as a string.
239 * @param[in] script The JavaScript code
240 * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result.
242 virtual void EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler) = 0;
245 * @brief Add a message handler into JavaScript.
247 * @param[in] exposedObjectName The name of exposed object
248 * @param[in] handler The callback function
250 virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler) = 0;
253 * @brief Clears all tiles resources of Web.
255 virtual void ClearAllTilesResources() = 0;
258 * @brief Clears the history of Web.
260 virtual void ClearHistory() = 0;
263 * @brief Get user agent string.
265 * @return The string value of user agent
267 virtual const std::string& GetUserAgent() const = 0;
270 * @brief Set user agent string.
272 * @param[in] userAgent The string value of user agent
274 virtual void SetUserAgent(const std::string& userAgent) = 0;
277 * @brief Sets size of Web Page.
279 virtual void SetSize(int width, int height) = 0;
282 * @brief Sends Touch Events.
284 virtual bool SendTouchEvent(const TouchEvent& touch) = 0;
287 * @brief Sends Key Events.
289 virtual bool SendKeyEvent(const KeyEvent& event) = 0;
294 virtual void SetFocus( bool focused ) = 0;
297 * @brief Connects to this signal to be notified when page loading is started.
299 * @return A signal object to connect with.
301 virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0;
304 * @brief Connects to this signal to be notified when page loading is finished.
306 * @return A signal object to connect with.
308 virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0;
311 * @brief Connects to this signal to be notified when an error occurs in page loading.
313 * @return A signal object to connect with.
315 virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0;
318 * @brief Connects to this signal to be notified when scroll edge is reached.
320 * @return A signal object to connect with.
322 virtual WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal() = 0;