X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fdevel-api%2Fadaptor-framework%2Fweb-engine.h;h=4ba8cbfa47d72a1085874cb8c18eb1dce4dded1a;hb=7f9f13e07e11fb8acbe4d0efdd04a5fa24b01348;hp=decb87c43b9dd43557109d1f3a74b97c8cffb76f;hpb=0b9a2d99cea6c0da882cedf22dfd066a913befe4;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/devel-api/adaptor-framework/web-engine.h b/dali/devel-api/adaptor-framework/web-engine.h old mode 100644 new mode 100755 index decb87c..4ba8cbf --- a/dali/devel-api/adaptor-framework/web-engine.h +++ b/dali/devel-api/adaptor-framework/web-engine.h @@ -2,7 +2,7 @@ #define DALI_WEB_ENGINE_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. @@ -27,13 +27,11 @@ namespace Dali { - namespace Internal { - namespace Adaptor { - class WebEngine; +class WebEngine; } // namespace Adaptor } // namespace Internal @@ -47,7 +45,6 @@ namespace Adaptor class DALI_ADAPTOR_API WebEngine : public BaseHandle { public: - /** * @brief Constructor. */ @@ -59,7 +56,7 @@ public: ~WebEngine(); /** - * @brief Creates a new instance of a WebEngine. + * @brief Create a new instance of a WebEngine. */ static WebEngine New(); @@ -68,7 +65,7 @@ public: * * @param[in] WebEngine WebEngine to copy. The copied WebEngine will point at the same implementation */ - WebEngine( const WebEngine& WebEngine ); + WebEngine(const WebEngine& WebEngine); /** * @brief Assignment operator. @@ -76,7 +73,7 @@ public: * @param[in] WebEngine The WebEngine to assign from. * @return The updated WebEngine. */ - WebEngine& operator=( const WebEngine& WebEngine ); + WebEngine& operator=(const WebEngine& WebEngine); /** * @brief Downcast a handle to WebEngine handle. @@ -87,98 +84,254 @@ public: * @param[in] handle Handle to an object * @return Handle to a WebEngine or an uninitialized handle */ - static WebEngine DownCast( BaseHandle handle ); + static WebEngine DownCast(BaseHandle handle); /** - * @brief Creates WebEngine instance. + * @brief Create WebEngine instance. * * @param [in] width The width of Web * @param [in] height The height of Web * @param [in] locale The locale of Web * @param [in] timezoneId The timezoneID of Web */ - void Create( int width, int height, const std::string& locale, const std::string& timezoneId ); + void Create(uint32_t width, uint32_t height, const std::string& locale, const std::string& timezoneId); /** - * @brief Destroys WebEngine instance. + * @brief Create WebEngine instance. + * + * @param [in] width The width of Web + * @param [in] height The height of Web + * @param [in] argc The count of application arguments + * @param [in] argv The string array of application arguments + */ + void Create(uint32_t width, uint32_t height, uint32_t argc, char** argv); + + /** + * @brief Destroy WebEngine instance. */ void Destroy(); /** - * @brief Gets native image source to render. + * @brief Get native image source to render. */ NativeImageInterfacePtr GetNativeImageSource(); /** - * @brief Loads a web page based on a given URL. + * @brief Get settings of WebEngine. + */ + Dali::WebEngineSettings& GetSettings() const; + + /** + * @brief Get context of WebEngine. + */ + Dali::WebEngineContext& GetContext() const; + + /** + * @brief Get cookie manager of WebEngine. + */ + Dali::WebEngineCookieManager& GetCookieManager() const; + + /** + * @brief Get back-forward list of WebEngine. + */ + Dali::WebEngineBackForwardList& GetBackForwardList() const; + + /** + * @brief Load a web page based on a given URL. * * @param [in] url The URL of the resource to load */ - void LoadUrl( const std::string& url ); + void LoadUrl(const std::string& url); + + /** + * @brief Return the title of the Web. + * + * @return The title of web page + */ + std::string GetTitle() const; + + /** + * @brief Return the Favicon of the Web. + * + * @return FavIcon of Dali::PixelData& type + */ + Dali::PixelData GetFavicon() const; /** - * @brief Gets the url. + * @brief Get the url. */ - const std::string& GetUrl(); + std::string GetUrl() const; /** - * @brief Loads a given string as web contents. + * @brief Load 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. + * @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 Request 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 Reload the Web. */ void Reload(); /** - * @brief Stops loading web contents on the current page. + * @brief Reload the current page's document without cache + */ + bool ReloadWithoutCache(); + + /** + * @brief Stop loading web contents on the current page. */ void StopLoading(); /** - * @brief Suspends the operation associated with the view. + * @brief Suspend the operation associated with the view. */ void Suspend(); /** - * @brief Resumes the operation associated with the view object after calling Suspend(). + * @brief Resume the operation associated with the view object after calling Suspend(). */ void Resume(); /** - * @brief Returns whether forward is possible. + * @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 Scroll web page of view by deltaX and deltaY. + * + * @param[in] deltaX horizontal offset to scroll + * @param[in] deltaY vertical offset to scroll + */ + void ScrollBy(int32_t deltaX, int32_t deltaY); + + /** + * @brief Scroll 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(int32_t deltaX, int32_t deltaY); + + /** + * @brief Set an absolute scroll of the given view. + */ + void SetScrollPosition(int32_t x, int32_t y); + + /** + * @brief Get the current scroll position of the given view. + */ + Dali::Vector2 GetScrollPosition() const; + + /** + * @brief Get the possible scroll size of the given view. + */ + Dali::Vector2 GetScrollSize() const; + + /** + * @brief Get the last known content's size. + */ + Dali::Vector2 GetContentSize() const; + + /** + * @brief Return whether forward is possible. * * @return True if forward is possible, false otherwise */ bool CanGoForward(); /** - * @brief Goes to forward. + * @brief Go to forward. */ void GoForward(); /** - * @brief Returns whether backward is possible. + * @brief Return whether backward is possible. * * @return True if backward is possible, false otherwise */ bool CanGoBack(); /** - * @brief Goes to back. + * @brief Go to back. */ void GoBack(); /** - * @brief Evaluates JavaScript code represented as a string. + * @brief Evaluate 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< void( const std::string& ) > resultHandler ); + void EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler); /** * @brief Add a message handler into JavaScript. @@ -186,165 +339,424 @@ public: * @param[in] exposedObjectName The name of exposed object * @param[in] handler The callback function */ - void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ); + void AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler); /** - * @brief Clears the history of Web. + * @brief Register a callback for JavaScript alert. + * + * @param[in] callback The callback function */ - void ClearHistory(); + void RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback); /** - * @brief Clears the cache of Web. + * @brief Reply for JavaScript alert. */ - void ClearCache(); + void JavaScriptAlertReply(); /** - * @brief Clears all the cookies of Web. + * @brief Register a callback for JavaScript confirm. + * + * @param[in] callback The callback function */ - void ClearCookies(); + void RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback); /** - * @brief Get cache model option. The default is DOCUMENT_VIEWER. - * - * @return The cache model option + * @brief Reply for JavaScript confirm. + * @param[in] confirmed True if confirmed, false otherwise. */ - Dali::WebEnginePlugin::CacheModel GetCacheModel() const; + void JavaScriptConfirmReply(bool confirmed); /** - * @brief Set cache model option. The default is DOCUMENT_VIEWER. + * @brief Register a callback for JavaScript prompt. * - * @param[in] cacheModel The cache model option + * @param[in] callback The callback function + */ + void RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback); + + /** + * @brief Reply for JavaScript prompt. + * @param[in] result The result returned from input-field in prompt popup. */ - void SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ); + void JavaScriptPromptReply(const std::string& result); /** - * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY. + * @brief Create a new hit test. * - * @return The cookie acceptance policy + * @param[in] x the horizontal position to query + * @param[in] y the vertical position to query + * @param[in] mode the mode of hit test + * + * @return a new hit test object */ - Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const; + std::unique_ptr CreateHitTest(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode); /** - * @brief Sets the cookie acceptance policy. The default is NO_THIRD_PARTY. + * @brief create a hit test asynchronously. + * + * @param[in] x the horizontal position to query + * @param[in] y the vertical position to query + * @param[in] mode the mode of hit test + * @param[in] callback the callback function * - * @param[in] policy The cookie acceptance policy + * @return true if succeeded, false otherwise + */ + bool CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode, Dali::WebEnginePlugin::WebEngineHitTestCreatedCallback callback); + + /** + * @brief Clear the history of Web. */ - void SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ); + void ClearHistory(); + + /** + * @brief Clear all tiles resources of Web. + */ + void ClearAllTilesResources(); /** * @brief Get user agent string. * * @return The string value of user agent */ - const std::string& GetUserAgent() const; + std::string GetUserAgent() const; /** * @brief Set user agent string. * * @param[in] userAgent The string value of user agent */ - void SetUserAgent( const std::string& userAgent ); + void SetUserAgent(const std::string& userAgent); + + /** + * @brief Set the size of Web Pages. + */ + void SetSize(uint32_t width, uint32_t height); + + /** + * @brief Set background color of web page. + * + * @param[in] color Background color + */ + void SetDocumentBackgroundColor(Dali::Vector4 color); + + /** + * @brief Clear tiles when hidden. + * + * @param[in] cleared Whether tiles are cleared or not + */ + void ClearTilesWhenHidden(bool cleared); /** - * @brief Returns whether JavaScript can be executable. The default is true. + * @brief Set multiplier of cover area of tile. * - * @return true if JavaScript executing is enabled, false otherwise + * @param[in] multiplier The multiplier of cover area */ - bool IsJavaScriptEnabled() const; + void SetTileCoverAreaMultiplier(float multiplier); /** - * @brief Enables/disables JavaScript executing. The default is enabled. + * @brief Enable cursor by client. * - * @param[in] enabled True if JavaScript executing is enabled, false otherwise + * @param[in] enabled Whether cursor is enabled or not */ - void EnableJavaScript( bool enabled ); + void EnableCursorByClient(bool enabled); /** - * @brief Returns whether JavaScript can be executable. The default is true. + * @brief Get the selected text. * - * @return true if images are loaded automatically, false otherwise + * @return the selected text + */ + std::string GetSelectedText() const; + + /** + * @brief Send Touch Events. */ - bool AreImagesAutomaticallyLoaded() const; + bool SendTouchEvent(const TouchEvent& touch); /** - * @brief Enables/disables auto loading of images. The default is enabled. + * @brief Send key Events. + */ + bool SendKeyEvent(const KeyEvent& event); + + /** + * @brief Set focus. + * @param[in] focused True if web view is focused, false otherwise + */ + void SetFocus(bool focused); + + /** + * @brief Enable/disable mouse events. The default is enabled. * - * @param[in] automatic True if images are loaded automatically, false otherwise + * @param[in] enabled True if mouse events are enabled, false otherwise */ - void LoadImagesAutomatically( bool automatic ); + void EnableMouseEvents(bool enabled); /** - * @brief Gets the default text encoding name. + * @brief Enable/disable key events. The default is enabled. * - * @return The default text encoding name + * @param[in] enabled True if key events are enabled, false otherwise */ - const std::string& GetDefaultTextEncodingName() const; + void EnableKeyEvents(bool enabled); /** - * @brief Sets the default text encoding name. + * @brief Set zoom factor of the current page. + * @param[in] zoomFactor a new factor to be set. + */ + void SetPageZoomFactor(float zoomFactor); + + /** + * @brief Query the current zoom factor of the page。 + * @return The current page zoom factor. + */ + float GetPageZoomFactor() const; + + /** + * @brief Set the current text zoom level。. + * @param[in] zoomFactor a new factor to be set. + */ + void SetTextZoomFactor(float zoomFactor); + + /** + * @brief Get the current text zoom level. + * @return The current text zoom factor. + */ + float GetTextZoomFactor() const; + + /** + * @brief Get the current load progress of the page. + * @return The load progress of the page. + */ + float GetLoadProgressPercentage() const; + + /** + * @brief Scale 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 Get 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 Request to set the current page's visibility. + * @param[in] visible Visible or not. + * + * @return true if changed successfully, false otherwise + */ + bool SetVisibility(bool visible); + + /** + * @brief Search 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 pixel data of screen shot + */ + Dali::PixelData GetScreenshot(Dali::Rect viewArea, float scaleFactor); + + /** + * @brief Request to get snapshot of the specified viewArea of page asynchronously. * - * @param[in] defaultTextEncodingName The default text encoding name + * @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 */ - void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ); + bool GetScreenshotAsynchronously(Dali::Rect viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback); /** - * @brief Returns the default font size in pixel. The default value is 16. + * @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 The default font size + * @return true if requested successfully, false otherwise */ - int GetDefaultFontSize() const; + bool CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback); /** - * @brief Sets the default font size in pixel. The default value is 16. + * @brief Set callback which alled upon geolocation permission request. * - * @param[in] defaultFontSize A new default font size to set + * @param[in] callback The callback for requesting geolocation permission */ - void SetDefaultFontSize( int defaultFontSize ); + void RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback); /** - * @brief Sets the size of Web Pages. + * @brief Update display area. + * @param[in] displayArea The area to display web page */ - void SetSize( int width, int height ); + void UpdateDisplayArea(Dali::Rect displayArea); /** - * @brief Sends Touch Events. + * @brief Enable video hole. + * @param[in] enabled True if video hole is enabled, false otherwise */ - bool SendTouchEvent( const TouchEvent& touch ); + void EnableVideoHole(bool enabled); /** - * @brief Sends key Events. + * @brief Send hover events. + * @param[in] event The hover event would be sent. */ - bool SendKeyEvent( const KeyEvent& event ); + bool SendHoverEvent(const HoverEvent& event); /** - * @brief Connects to this signal to be notified when page loading is started. + * @brief Send wheel events. + * @param[in] event The wheel event would be sent. + */ + bool SendWheelEvent(const WheelEvent& event); + + /** + * @brief Connect to this signal to be notified when frame is rendered. * * @return A signal object to connect with. */ - Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal(); + Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal(); /** - * @brief Connects to this signal to be notified when page loading is finished. + * @brief Callback to be called when page loading is started. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal(); + void RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback); /** - * @brief Connects to this signal to be notified when an error occurs in page loading. + * @brief Callback to be called when page loading is in progress. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal(); + void RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback); -private: // Not intended for application developers + /** + * @brief Callback to be called when page loading is finished. + * + * @param[in] callback + */ + void RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback); + + /** + * @brief Callback to be called when an error occurs in page loading. + * + * @param[in] callback + */ + void RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback); /** + * @brief Callback to be called when scroll edge is reached. + * + * @param[in] callback + */ + void RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback); + + /** + * @brief Callback to be called when url is changed. + * + * @param[in] callback + */ + void RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback); + + /** + * @brief Callback to be called when form repost decision is requested. + * + * @param[in] callback + */ + void RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback); + + /** + * @brief Callback to be called when http request need be intercepted. + * + * @param[in] callback + */ + void RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback); + + /** + * @brief Callback to be called when console message will be logged. + * + * @param[in] callback + */ + void RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback); + + /** + * @brief Callback to be called when response policy would be decided. + * + * @param[in] callback + */ + void RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback); + + /** + * @brief Callback to be called when certificate need be confirmed. + * + * @param[in] callback + */ + void RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback); + + /** + * @brief Callback to be called when ssl certificate is changed. + * + * @param[in] callback + */ + void RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback); + + /** + * @brief Callback to be called when http authentication need be confirmed. + * + * @param[in] callback + */ + void RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback); + + /** + * @brief Callback to be called when context menu would be shown. + * + * @param[in] callback + */ + void RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback); + + /** + * @brief Callback to be called when context menu would be hidden. + * + * @param[in] callback + */ + void RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback); + + /** + * @brief Get a plain text of current web page asynchronously. + * + * @param[in] callback The callback function called asynchronously. + */ + void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback); + +private: // Not intended for application developers + /** * @brief Internal constructor */ - explicit DALI_INTERNAL WebEngine( Internal::Adaptor::WebEngine* internal ); + explicit DALI_INTERNAL WebEngine(Internal::Adaptor::WebEngine* internal); }; -} // namespace Dali; +} // namespace Dali #endif // DALI_WEB_ENGINE_H