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=d307d76d5c6da4a77794379edef573b2db21a579;hp=53dfb5a5af94123ec7bc24cefa456cf4ba32dbb9;hb=ca1f0e15a7bb259871c16968340b76afe7e169c6;hpb=9a3b70ae29875d69b4ca7a3ff5dd2051c3d053de diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h index 53dfb5a..d307d76 100755 --- 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) 2020 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. @@ -20,10 +20,11 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES -#include #include +#include namespace Dali { @@ -33,6 +34,7 @@ class ImageView; class WebBackForwardList; class WebContext; class WebCookieManager; +class WebFormRepostDecision; class WebSettings; namespace Internal DALI_INTERNAL @@ -56,7 +58,6 @@ class WebView; class DALI_TOOLKIT_API WebView : public Control { public: - /** * @brief Enumeration for the start and end property ranges for this control. */ @@ -81,132 +82,159 @@ public: /** * @brief The user agent string. - * @details Name "userAgent", type Property::STRING. + * @details name "userAgent", type Property::STRING. */ USER_AGENT, /** * @brief The current position of scroll. - * @details Name "scrollPosition", type Property::VECTOR2. + * @details name "scrollPosition", type Property::VECTOR2. */ SCROLL_POSITION, /** - * @brief The current position of scroll. - * @details Name "scrollSize", type Property::VECTOR2. Read-only. + * @brief The current size of scroll. + * @details name "scrollSize", type Property::VECTOR2. + * @note The value is read-only. */ SCROLL_SIZE, /** - * @brief The current position of scroll. - * @details Name "contentSize", type Property::VECTOR2. Read-only. + * @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. + * @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. + */ + 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, + + /** + * @brief Zoom factor of web page. + * @details name "pageZoomFactor", type Property::FLOAT. + */ + PAGE_ZOOM_FACTOR, + + /** + * @brief Zoom factor of text. + * @details name "textZoomFactor", type Property::FLOAT. + */ + TEXT_ZOOM_FACTOR, + + /** + * @brief progress percentage of loading a web page. + * @details name "loadProgressPercentage", type Property::FLOAT. + * @note The value is read-only. + */ + LOAD_PROGRESS_PERCENTAGE, }; }; /** - * @brief Enumeration for indicating error code of page loading. + * @brief WebView callback related with screen-shot captured. */ - 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 - }; + using WebViewScreenshotCapturedCallback = std::function; /** * @brief WebView signal type related with page loading. */ - typedef Signal WebViewPageLoadSignalType; + using WebViewPageLoadSignalType = Signal; /** * @brief WebView signal type related with page loading error. */ - typedef Signal WebViewPageLoadErrorSignalType; + using WebViewPageLoadErrorSignalType = Signal)>; /** * @brief WebView signal type related with scroll edge reached. */ - typedef Signal WebViewScrollEdgeReachedSignalType; + using WebViewScrollEdgeReachedSignalType = Signal; + + /** + * @brief WebView signal type related with url changed. + */ + using WebViewUrlChangedSignalType = Signal; + + /** + * @brief WebView signal type related with form repost decision. + */ + using WebViewFormRepostDecisionSignalType = Signal)>; + + /** + * @brief WebView signal type related with frame rendered. + */ + using WebViewFrameRenderedSignalType = Signal; + + /** + * @brief WebView signal type related with http request interceptor. + */ + using WebViewRequestInterceptorSignalType = Signal)>; + + /** + * @brief WebView signal type related with console message. + */ + using WebViewConsoleMessageSignalType = Signal)>; + + /** + * @brief WebView signal type related with policy decision. + */ + using WebViewPolicyDecisionSignalType = Signal)>; public: /** @@ -231,7 +259,7 @@ public: * @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 ); + static WebView New(int argc, char** argv); /** * @brief Creates an uninitialized WebView. @@ -313,11 +341,40 @@ public: void LoadHtmlString(const std::string& htmlString); /** + * @brief Load the specified html string as the content of the view overriding current history entry + * + * @param[in] html HTML data to load + * @param[in] basicUri Base URL used for relative paths to external objects + * @param[in] unreachableUrl URL that could not be reached + * + * @return true if successfully loaded, false otherwise + */ + bool LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl); + + /** + * @brief Requests loading the given contents by MIME type into the view object + * + * @param[in] contents The content to load + * @param[in] contentSize The size of contents (in bytes) + * @param[in] mimeType The type of contents, if 0 is given "text/html" is assumed + * @param[in] encoding The encoding for contents, if 0 is given "UTF-8" is assumed + * @param[in] baseUri The base URI to use for relative resources + * + * @return true if successfully request, false otherwise + */ + bool LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri); + + /** * @brief Reloads the Web. */ void Reload(); /** + * @brief Reloads the current page's document without cache + */ + bool ReloadWithoutCache(); + + /** * @brief Stops loading web contents on the current page. */ void StopLoading(); @@ -333,11 +390,66 @@ public: void Resume(); /** - * @brief Scrolls the webpage of view by deltaX and deltaY. + * @brief To suspend all url loading + */ + void SuspendNetworkLoading(); + + /** + * @brief To resume new url network loading + */ + void ResumeNetworkLoading(); + + /** + * @brief Add custom header + * + * @param[in] name custom header name to add the custom header + * @param[in] value custom header value to add the custom header + * + * @return true if succeeded, false otherwise + */ + bool AddCustomHeader(const std::string& name, const std::string& value); + + /** + * @brief Remove custom header + * + * @param[in] name custom header name to remove the custom header + * + * @return true if succeeded, false otherwise + */ + bool RemoveCustomHeader(const std::string& name); + + /** + * @brief Start the inspector server + * + * @param[in] port port number + * + * @return the port number + */ + uint32_t StartInspectorServer(uint32_t port); + + /** + * @brief Stop the inspector server + * + * @return true if succeeded, false otherwise + */ + bool StopInspectorServer(); + + /** + * @brief Scrolls web page 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 ); + void ScrollBy(int deltaX, int deltaY); + + /** + * @brief Scrolls edge of view by deltaX and deltaY. + * + * @param[in] deltaX horizontal offset to scroll + * @param[in] deltaY vertical offset to scroll + * + * @return true if succeeded, false otherwise + */ + bool ScrollEdgeBy(int deltaX, int deltaY); /** * @brief Returns whether forward is possible. @@ -367,7 +479,7 @@ public: * @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. + * @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); @@ -405,9 +517,42 @@ public: void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler); /** - * @brief Clears all tiles resources of Web. + * @brief Register alert callback for javascript. + * + * @param[in] callback The callback function to be called by the JavaScript runtime. */ - void ClearAllTilesResources(); + 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 Reply for JavaScript confirm. + * @param[in] confirmed True if confirmed, false otherwise + */ + void JavaScriptConfirmReply(bool confirmed); + + /** + * @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. @@ -415,6 +560,84 @@ public: void ClearHistory(); /** + * @brief Clears all tiles resources of Web. + */ + void ClearAllTilesResources(); + + /** + * @brief Scales the current page, centered at the given point. + * @param[in] scaleFactor a new factor to be scaled. + * @param[in] point a center coordinate. + */ + void SetScaleFactor(float scaleFactor, Dali::Vector2 point); + + /** + * @brief Gets the current scale factor of the page. + * @return The current scale factor. + */ + float GetScaleFactor() const; + + /** + * @brief Request to activate/deactivate the accessibility usage set by web app. + * @param[in] activated Activate accessibility or not. + */ + void ActivateAccessibility(bool activated); + + /** + * @brief Searches and highlights the given string in the document. + * @param[in] text The text to find + * @param[in] options The options to find + * @param[in] maxMatchCount The maximum match count to find + * + * @return true if found & highlighted, false otherwise + */ + bool HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount); + + /** + * @brief Add dynamic certificate path. + * @param[in] host host that required client authentication + * @param[in] certPath the file path stored certificate + */ + void AddDynamicCertificatePath(const std::string& host, const std::string& certPath); + + /** + * @brief Get snapshot of the specified viewArea of page. + * + * @param[in] viewArea The rectangle of screen shot + * @param[in] scaleFactor The scale factor + * + * @return image view of screen shot + */ + Dali::Toolkit::ImageView GetScreenshot(Dali::Rect viewArea, float scaleFactor); + + /** + * @brief Request to get snapshot of the specified viewArea of page asynchronously. + * + * @param[in] viewArea The rectangle of screen shot + * @param[in] scaleFactor The scale factor + * @param[in] callback The callback for screen shot + * + * @return true if requested successfully, false otherwise + */ + bool GetScreenshotAsynchronously(Dali::Rect viewArea, float scaleFactor, WebViewScreenshotCapturedCallback callback); + + /** + * @brief Asynchronous request to check if there is a video playing in the given view. + * + * @param[in] callback The callback called after checking if video is playing or not + * + * @return true if requested successfully, false otherwise + */ + bool CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback); + + /** + * @brief Sets callback which will be called upon geolocation permission request. + * + * @param[in] callback The callback for requesting geolocation permission + */ + void RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback); + + /** * @brief Connects to this signal to be notified when page loading is started. * * @return A signal object to connect with @@ -422,6 +645,13 @@ public: 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 @@ -431,17 +661,59 @@ public: /** * @brief Connects to this signal to be notified when an error occurs in page loading. * - * @return A signal object to connect with. + * @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. + * @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(); + + /** + * @brief Connects to this signal to be notified when form repost decision is requested. + * + * @return A signal object to connect with. + */ + WebViewFormRepostDecisionSignalType& FormRepostDecisionSignal(); + + /** + * @brief Connects to this signal to be notified when frame is rendered. + * + * @return A signal object to connect with. + */ + WebViewFrameRenderedSignalType& FrameRenderedSignal(); + + /** + * @brief Connects to this signal to be notified when http request need be intercepted. + * + * @return A signal object to connect with. + */ + WebViewRequestInterceptorSignalType& RequestInterceptorSignal(); + + /** + * @brief Connects to this signal to be notified when console message will be logged. + * + * @return A signal object to connect with. + */ + WebViewConsoleMessageSignalType& ConsoleMessageSignal(); + + /** + * @brief Connects to this signal to be notified when new policy would be decided. + * + * @return A signal object to connect with. + */ + WebViewPolicyDecisionSignalType& PolicyDecisionSignal(); + public: // Not intended for application developers /// @cond internal /**