1 #ifndef DALI_TOOLKIT_WEB_VIEW_H
2 #define DALI_TOOLKIT_WEB_VIEW_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <dali-toolkit/public-api/controls/control.h>
33 namespace Internal DALI_INTERNAL
36 } // namespace Internal
39 * @addtogroup dali_toolkit_controls_web_view
44 * @brief WebView is a control for displaying web content.
46 * This enables embedding web pages in the application.
48 * For working WebView, a web engine plugin for a platform should be provided.
51 class DALI_TOOLKIT_API WebView : public Control
56 * @brief Enumeration for the start and end property ranges for this control.
60 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
61 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000,
65 * @brief Enumeration for the instance of properties belonging to the WebView class.
72 * @brief name "url", type string
74 * @details Sets the url to load
76 URL = PROPERTY_START_INDEX
80 typedef Signal< void ( WebView, const std::string& ) > WebViewSignalType;
85 * @brief Creates an initialized WebView.
86 * @return A handle to a newly allocated Dali WebView
88 * @note WebView will not display anything
93 * @brief Creates an initialized WebView.
95 * @param [in] locale The locale of Web
96 * @param [in] timezoneId The timezoneId of Web
98 static WebView New( const std::string& locale, const std::string& timezoneId );
101 * @brief Creates an uninitialized WebView.
108 * This is non-virtual since derived Handel types must not contain data or virtual methods.
113 * @brief Copy constructor.
115 * @param[in] WebView WebView to copy. The copied WebView will point at the same implementation
117 WebView( const WebView& WebView );
120 * @brief Assignment operator.
122 * @param[in] WebView The WebView to assign from
123 * @return The updated WebView
125 WebView& operator=( const WebView& WebView );
128 * @brief Downcasts a handle to WebView handle.
130 * If handle points to a WebView, the downcast produces valid handle.
131 * If not, the returned handle is left uninitialized.
133 * @param[in] handle Handle to an object
134 * @return Handle to a WebView or an uninitialized handle
136 static WebView DownCast( BaseHandle handle );
139 * @brief Loads a web page based on a given URL.
141 * @param [in] url The URL of the resource to load
143 void LoadUrl( const std::string& url );
146 * @brief Returns the URL of the Web.
148 * @return Url of string type
150 const std::string& GetUrl();
153 * @brief Loads a given string as web contents.
155 * @param [in] htmlString The string to use as the contents of the web page
157 void LoadHTMLString( const std::string& htmlString );
160 * @brief Reloads the Web.
165 * @brief Stops loading web contents on the current page.
170 * @brief Returns whether forward is possible.
172 * @return True if forward is possible, false otherwise
177 * @brief Goes forward in the navigation history.
182 * @brief Returns whether backward is possible.
184 * @return True if backward is possible, false otherwise
189 * @brief Goes back in the navigation history.
194 * @brief Evaluates JavaScript code represented as a string.
196 * @param[in] script The JavaScript code
198 void EvaluateJavaScript( const std::string& script );
201 * @brief Adds a JavaScript interface.
203 * @param[in] exposedObjectName The name of exposed object
204 * @param[in] jsFunctionName The name of JavaScript function
205 * @param[in] callback The callback function
207 void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback );
210 * @brief Removes a JavaScript interface.
212 * @param[in] exposedObjectName The name of exposed object
213 * @param[in] jsFunctionName The name of JavaScript function
215 void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName );
218 * @brief Clears the history of Web.
223 * @brief Clears the cache of Web.
228 * @brief Connects to this signal to be notified when page loading is started.
230 * @return A signal object to connect with
232 WebViewSignalType& PageLoadStartedSignal();
235 * @brief Connects to this signal to be notified when page loading is finished.
237 * @return A signal object to connect with
239 WebViewSignalType& PageLoadFinishedSignal();
241 public: // Not intended for application developers
245 * @brief Creates a handle using the Toolkit::Internal implementation.
247 * @param[in] implementation The WebView implementation
249 DALI_INTERNAL WebView( Internal::WebView& implementation );
252 * @brief Allows the creation of this WebView from an Internal::CustomActor pointer.
254 * @param[in] internal A pointer to the internal CustomActor
256 explicit DALI_INTERNAL WebView( Dali::Internal::CustomActor* internal );
265 } // namespace Toolkit
269 #endif // DALI_TOOLKIT_WEB_VIEW_H