X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fcontrols%2Fweb-view%2Fweb-view.h;h=2bb556e66aa9727727eab6c788465935a12892ca;hp=71d05d3f54c9e0b6b6f74c31da0a0126b01af49b;hb=3890e8d5e0d6c13b7a20538b0de12125946f6d87;hpb=2b6baa7ad447110327e4ac22e7b3c3b6524c14da diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h old mode 100644 new mode 100755 index 71d05d3..2bb556e --- a/dali-toolkit/devel-api/controls/web-view/web-view.h +++ b/dali-toolkit/devel-api/controls/web-view/web-view.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_WEB_VIEW_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,17 +23,22 @@ // INTERNAL INCLUDES #include +#include namespace Dali { - namespace Toolkit { +class ImageView; +class WebBackForwardList; +class WebContext; +class WebCookieManager; +class WebSettings; namespace Internal DALI_INTERNAL { - class WebView; -} // namespace Internal +class WebView; +} // namespace DALI_INTERNAL /** * @addtogroup dali_toolkit_controls_web_view @@ -51,14 +56,13 @@ namespace Internal DALI_INTERNAL class DALI_TOOLKIT_API WebView : public Control { public: - /** * @brief Enumeration for the start and end property ranges for this control. */ enum PropertyRange { PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, - PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, + PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, }; /** @@ -69,19 +73,142 @@ public: enum { /** - * @brief name "url", type string - * - * @details Sets the url to load + * @brief The url to load. + * @details name "url", type Property::STRING. + */ + URL = PROPERTY_START_INDEX, + + /** + * @brief The user agent string. + * @details name "userAgent", type Property::STRING. + */ + USER_AGENT, + + /** + * @brief The current position of scroll. + * @details name "scrollPosition", type Property::VECTOR2. + */ + SCROLL_POSITION, + + /** + * @brief The current size of scroll. + * @details name "scrollSize", type Property::VECTOR2. + * @note The value is read-only. + */ + SCROLL_SIZE, + + /** + * @brief The current size of content. + * @details name "contentSize", type Property::VECTOR2. + * @note The value is read-only. + */ + CONTENT_SIZE, + + /** + * @brief The title of web page. + * @details name "title", type Property::STRING. + * @note The value is read-only. + */ + TITLE, + + /** + * @brief Whether video hole is enabled or not. + * @details name "videoHoleEnabled", type Property::BOOLEAN. + * @note The value is read-only. + */ + VIDEO_HOLE_ENABLED, + + /** + * @brief Whether mouse event is enabled. + * @details name "mouseEventsEnabled", type Property::BOOLEAN. + * @note Default is true. + */ + MOUSE_EVENTS_ENABLED, + + /** + * @brief Whether key event is enabled. + * @details name "keyEventsEnabled", type Property::BOOLEAN. + * @note Default is true. + */ + KEY_EVENTS_ENABLED, + + /** + * @brief The background color of web page. + * @details name "documentBackgroundColor", type Property::VECTOR4. + */ + DOCUMENT_BACKGROUND_COLOR, + + /** + * @brief Whether tiles can be cleared or not when hidden. + * @details name "tilesClearedWhenHidden", type BOOLEAN. */ - URL = PROPERTY_START_INDEX + TILES_CLEARED_WHEN_HIDDEN, + + /** + * @brief The multiplier of cover area of tile when rendering web page. + * @details name "tileCoverAreaMultiplier", type FLOAT. + */ + TILE_COVER_AREA_MULTIPLIER, + + /** + * @brief Whether cursor is enabled or not by client. + * @details name "cursorEnabledByClient", type BOOLEAN. + */ + CURSOR_ENABLED_BY_CLIENT, + + /** + * @brief The selected text of web page. + * @details name "selectedText", type Property::STRING. + * @note The value is read-only. + */ + SELECTED_TEXT, }; }; - typedef Signal< void ( WebView, const std::string& ) > WebViewSignalType; + /** + * @brief Enumeration for indicating error code of page loading. + */ + enum class LoadErrorCode + { + UNKNOWN = 0, ///< Unknown. + CANCELED, ///< User canceled. + CANT_SUPPORT_MIMETYPE, ///< Can't show the page for this MIME type. + FAILED_FILE_IO, ///< File IO error. + CANT_CONNECT, ///< Cannot connect to the network. + CANT_LOOKUP_HOST, ///< Fail to look up host from the DNS. + FAILED_TLS_HANDSHAKE, ///< Fail to SSL/TLS handshake. + INVALID_CERTIFICATE, ///< Received certificate is invalid. + REQUEST_TIMEOUT, ///< Connection timeout. + TOO_MANY_REDIRECTS, ///< Too many redirects. + TOO_MANY_REQUESTS, ///< Too many requests during this load. + BAD_URL, ///< Malformed URL. + UNSUPPORTED_SCHEME, ///< Unsupported scheme. + AUTHENTICATION, ///< User authentication failed on the server. + INTERNAL_SERVER ///< Web server has an internal server error. + }; + + /** + * @brief WebView signal type related with page loading. + */ + using WebViewPageLoadSignalType = Signal; -public: + /** + * @brief WebView signal type related with page loading error. + */ + using WebViewPageLoadErrorSignalType = Signal; + + /** + * @brief WebView signal type related with scroll edge reached. + */ + using WebViewScrollEdgeReachedSignalType = Signal; /** + * @brief WebView signal type related with url changed. + */ + using WebViewUrlChangedSignalType = Signal; + +public: + /** * @brief Creates an initialized WebView. * @return A handle to a newly allocated Dali WebView * @@ -95,7 +222,15 @@ public: * @param [in] locale The locale of Web * @param [in] timezoneId The timezoneId of Web */ - static WebView New( const std::string& locale, const std::string& timezoneId ); + static WebView New(const std::string& locale, const std::string& timezoneId); + + /** + * @brief Creates an initialized WebView. + * + * @param [in] argc The count of arguments of Applications + * @param [in] argv The string array of arguments of Applications + */ + static WebView New(int argc, char** argv); /** * @brief Creates an uninitialized WebView. @@ -114,7 +249,7 @@ public: * * @param[in] WebView WebView to copy. The copied WebView will point at the same implementation */ - WebView( const WebView& WebView ); + WebView(const WebView& WebView); /** * @brief Assignment operator. @@ -122,7 +257,7 @@ public: * @param[in] WebView The WebView to assign from * @return The updated WebView */ - WebView& operator=( const WebView& WebView ); + WebView& operator=(const WebView& WebView); /** * @brief Downcasts a handle to WebView handle. @@ -133,28 +268,48 @@ public: * @param[in] handle Handle to an object * @return Handle to a WebView or an uninitialized handle */ - static WebView DownCast( BaseHandle handle ); + static WebView DownCast(BaseHandle handle); /** - * @brief Loads a web page based on a given URL. + * @brief Get WebSettings of WebEngine. + */ + Dali::Toolkit::WebSettings* GetSettings() const; + + /** + * @brief Get WebContext of WebEngine. + */ + Dali::Toolkit::WebContext* GetContext() const; + + /** + * @brief Get CookieManager of WebEngine. + */ + Dali::Toolkit::WebCookieManager* GetCookieManager() const; + + /** + * @brief Get WebBackForwardList of WebEngine. + */ + Dali::Toolkit::WebBackForwardList* GetBackForwardList() const; + + /** + * @brief Get Favicon of web page. * - * @param [in] url The URL of the resource to load + * @return Handle to a fav icon */ - void LoadUrl( const std::string& url ); + Dali::Toolkit::ImageView& GetFavicon(); /** - * @brief Returns the URL of the Web. + * @brief Loads a web page based on a given URL. * - * @return Url of string type + * @param [in] url The URL of the resource to load */ - const std::string& GetUrl(); + void LoadUrl(const std::string& url); /** * @brief Loads a given string as web contents. * * @param [in] htmlString The string to use as the contents of the web page */ - void LoadHTMLString( const std::string& htmlString ); + void LoadHtmlString(const std::string& htmlString); /** * @brief Reloads the Web. @@ -167,6 +322,23 @@ public: void StopLoading(); /** + * @brief Suspends the operation associated with the view. + */ + void Suspend(); + + /** + * @brief Resumes the operation associated with the view object after calling Suspend(). + */ + void Resume(); + + /** + * @brief Scrolls the webpage of view by deltaX and deltaY. + * @param[in] deltaX The delta x of scroll + * @param[in] deltaY The delta y of scroll + */ + void ScrollBy(int deltaX, int deltaY); + + /** * @brief Returns whether forward is possible. * * @return True if forward is possible, false otherwise @@ -191,28 +363,83 @@ public: void GoBack(); /** - * @brief Evaluates JavaScript code represented as a string. - * - * @param[in] script The JavaScript code - */ - void EvaluateJavaScript( const std::string& script ); + * @brief Evaluates JavaScript code represented as a string. + * + * @param[in] script The JavaScript code + * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result. + */ + void EvaluateJavaScript(const std::string& script, std::function resultHandler); + + /** + * @brief Evaluates JavaScript code represented as a string. + * + * @param[in] script The JavaScript code + */ + void EvaluateJavaScript(const std::string& script); + + /** + * @brief Inject a JavaScript object with a message handler into the WebView. + * + * @note The injected object will appear in the JavaScript context to be loaded next. + * + * Example: + * + * 1. Native + * + * webview.AddJavaScriptMessageHandler( "myObject", []( const std::string& message ) { + * printf( "Received a message from JS: %s", message.c_str() ); + * }); + * + * // Start WebView by loading URL + * webview.LoadUrl( url ); + * + * 2. JavaScript + * + * myObject.postMessage( "Hello World!" ); // "Received a message from JS: Hello World!" + * + * + * @param[in] exposedObjectName The name of exposed object + * @param[in] handler The callback function + */ + void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler); + + /** + * @brief Register alert callback for javascript. + * + * @param[in] callback The callback function to be called by the JavaScript runtime. + */ + void RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback); + + /** + * @brief Reply for JavaScript alert. + */ + void JavaScriptAlertReply(); + + /** + * @brief Register confirm callback for javascript. + * + * @param[in] callback The callback function to be called by the JavaScript runtime. + */ + void RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback); /** - * @brief Adds a JavaScript interface. - * - * @param[in] exposedObjectName The name of exposed object - * @param[in] jsFunctionName The name of JavaScript function - * @param[in] callback The callback function - */ - void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback ); + * @brief Reply for JavaScript confirm. + * @param[in] confirmed True if confirmed, false otherwise + */ + void JavaScriptConfirmReply(bool confirmed); /** - * @brief Removes a JavaScript interface. - * - * @param[in] exposedObjectName The name of exposed object - * @param[in] jsFunctionName The name of JavaScript function - */ - void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName ); + * @brief Register prompt callback for javascript. + * + * @param[in] callback The callback function to be called by the JavaScript runtime. + */ + void RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback); + + /** + * @brief Reply for JavaScript prompt. + * @param[in] result The result from input-field of prompt popup. + */ + void JavaScriptPromptReply(const std::string& result); /** * @brief Clears the history of Web. @@ -220,42 +447,68 @@ public: void ClearHistory(); /** - * @brief Clears the cache of Web. + * @brief Clears all tiles resources of Web. */ - void ClearCache(); + void ClearAllTilesResources(); /** * @brief Connects to this signal to be notified when page loading is started. * * @return A signal object to connect with */ - WebViewSignalType& PageLoadStartedSignal(); + WebViewPageLoadSignalType& PageLoadStartedSignal(); + + /** + * @brief Connects to this signal to be notified when page loading is in progress. + * + * @return A signal object to connect with. + */ + WebViewPageLoadSignalType& PageLoadInProgressSignal(); /** * @brief Connects to this signal to be notified when page loading is finished. * * @return A signal object to connect with */ - WebViewSignalType& PageLoadFinishedSignal(); + WebViewPageLoadSignalType& PageLoadFinishedSignal(); -public: // Not intended for application developers + /** + * @brief Connects to this signal to be notified when an error occurs in page loading. + * + * @return A signal object to connect with. + */ + WebViewPageLoadErrorSignalType& PageLoadErrorSignal(); + /** + * @brief Connects to this signal to be notified when scroll edge is reached. + * + * @return A signal object to connect with. + */ + WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal(); + + /** + * @brief Connects to this signal to be notified when url is changed. + * + * @return A signal object to connect with. + */ + WebViewUrlChangedSignalType& UrlChangedSignal(); + +public: // Not intended for application developers /// @cond internal /** * @brief Creates a handle using the Toolkit::Internal implementation. * * @param[in] implementation The WebView implementation */ - DALI_INTERNAL WebView( Internal::WebView& implementation ); + DALI_INTERNAL WebView(Internal::WebView& implementation); /** * @brief Allows the creation of this WebView from an Internal::CustomActor pointer. * * @param[in] internal A pointer to the internal CustomActor */ - explicit DALI_INTERNAL WebView( Dali::Internal::CustomActor* internal ); + explicit DALI_INTERNAL WebView(Dali::Internal::CustomActor* internal); /// @endcond - }; /**