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=48e57cecd435d5d3e59911c905a8f6feaf7aad60;hp=71d05d3f54c9e0b6b6f74c31da0a0126b01af49b;hb=8d7facdc053ca256566f8e91c180b9027692ef2a;hpb=7098ad0a9a657b68b37d5fd759662a2d08b47433 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..48e57ce --- 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) 2020 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. @@ -22,18 +22,23 @@ #include // 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 @@ -58,7 +63,7 @@ public: 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 +74,92 @@ 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. */ - URL = PROPERTY_START_INDEX + 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, }; }; - 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< void( WebView, const std::string& ) >; -public: + /** + * @brief WebView signal type related with page loading error. + */ + using WebViewPageLoadErrorSignalType = Signal< void( WebView, const std::string&, LoadErrorCode ) >; /** + * @brief WebView signal type related with scroll edge reached. + */ + using WebViewScrollEdgeReachedSignalType = Signal< void( WebView, Dali::WebEnginePlugin::ScrollEdge ) >; + +public: + /** * @brief Creates an initialized WebView. * @return A handle to a newly allocated Dali WebView * @@ -95,7 +173,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 +200,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 +208,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 +219,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 +273,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,71 +314,100 @@ 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 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 Evaluates JavaScript code represented as a string. + * + * @param[in] script The JavaScript code + */ + void EvaluateJavaScript(const std::string& script); /** - * @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 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 Clears the history of Web. + * @brief Clears all tiles resources of Web. */ - void ClearHistory(); + void ClearAllTilesResources(); /** - * @brief Clears the cache of Web. + * @brief Clears the history of Web. */ - void ClearCache(); + void ClearHistory(); /** * @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 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(); + +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 - }; /**