X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fcontrols%2Fweb-view%2Fweb-view.h;h=2fa6433500bfcf953f0c7ffa80de9939001888fa;hb=88f5c28e662678cc93e13a2bcc462ff2446012c1;hp=71d05d3f54c9e0b6b6f74c31da0a0126b01af49b;hpb=7098ad0a9a657b68b37d5fd759662a2d08b47433;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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..2fa6433 --- 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,22 @@ #include // INTERNAL INCLUDES +#include #include namespace Dali { - namespace Toolkit { +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 +62,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 +73,135 @@ 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 position of scroll. + * @details Name "scrollSize", type Property::VECTOR2. Read-only. */ - URL = PROPERTY_START_INDEX + SCROLL_SIZE, + + /** + * @brief The current position of scroll. + * @details Name "contentSize", type Property::VECTOR2. Read-only. + */ + CONTENT_SIZE, }; }; - typedef Signal< void ( WebView, const std::string& ) > WebViewSignalType; + /** + * @brief Enumeration for indicating error code of page loading. + */ + enum class LoadErrorCode + { + /** + * @brief Unknown. + */ + UNKNOWN = 0, + + /** + * @brief User canceled. + */ + CANCELED, + + /** + * @brief Can't show the page for this MIME type. + */ + CANT_SUPPORT_MIMETYPE, + + /** + * @brief File IO error. + */ + FAILED_FILE_IO, + + /** + * @brief Cannot connect to the network. + */ + CANT_CONNECT, + + /** + * @brief Fail to look up host from the DNS. + */ + CANT_LOOKUP_HOST, + + /** + * @brief Fail to SSL/TLS handshake. + */ + FAILED_TLS_HANDSHAKE, + + /** + * @brief Received certificate is invalid. + */ + INVALID_CERTIFICATE, + + /** + * @brief Connection timeout. + */ + REQUEST_TIMEOUT, + + /** + * @brief Too many redirects. + */ + TOO_MANY_REDIRECTS, + + /** + * @brief Too many requests during this load. + */ + TOO_MANY_REQUESTS, + + /** + * @brief Malformed URL. + */ + BAD_URL, + + /** + * @brief Unsupported scheme. + */ + UNSUPPORTED_SCHEME, + + /** + * @brief User authentication failed on the server. + */ + AUTHENTICATION, + + /** + * @brief Web server has an internal server error. + */ + INTERNAL_SERVER + }; -public: + /** + * @brief WebView signal type related with page loading. + */ + typedef Signal WebViewPageLoadSignalType; /** + * @brief WebView signal type related with page loading error. + */ + typedef Signal WebViewPageLoadErrorSignalType; + + /** + * @brief WebView signal type related with scroll edge reached. + */ + typedef Signal WebViewScrollEdgeReachedSignalType; + +public: + /** * @brief Creates an initialized WebView. * @return A handle to a newly allocated Dali WebView * @@ -95,7 +215,7 @@ 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 uninitialized WebView. @@ -114,7 +234,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 +242,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 +253,41 @@ 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. - * - * @param [in] url The URL of the resource to load + * @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. */ - void LoadUrl( const std::string& url ); + Dali::Toolkit::WebBackForwardList* GetBackForwardList() const; /** - * @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 +300,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 +341,45 @@ 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. @@ -220,42 +387,49 @@ public: void ClearHistory(); /** - * @brief Clears the cache of Web. - */ - void ClearCache(); - - /** * @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 - }; /**