1 #ifndef DALI_TOOLKIT_INTERNAL_WEB_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_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.
22 #include <dali/devel-api/adaptor-framework/web-engine.h>
23 #include <dali/public-api/images/image-operations.h>
26 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
27 #include <dali-toolkit/public-api/controls/control-impl.h>
28 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
43 class WebView : public Control
49 WebView( const std::string& locale, const std::string& timezoneId );
56 * @copydoc Dali::Toolkit::WebView::New()
58 static Toolkit::WebView New();
61 * @copydoc Dali::Toolkit::WebView::New( const std::string&, const std::string& )
63 static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId );
66 * @copydoc Dali::Toolkit::WebView::LoadUrl()
68 void LoadUrl( const std::string& url );
71 * @copydoc Dali::Toolkit::WebView::GetUrl()
73 const std::string& GetUrl();
76 * @copydoc Dali::WebEngine::LoadHTMLString()
78 void LoadHTMLString( const std::string& htmlString );
81 * @copydoc Dali::WebEngine::Reload()
86 * @copydoc Dali::WebEngine::StopLoading()
91 * @copydoc Dali::WebEngine::CanGoForward()
96 * @copydoc Dali::WebEngine::GoForward()
101 * @copydoc Dali::WebEngine::CanGoBack()
106 * @copydoc Dali::WebEngine::GoBack()
111 * @copydoc Dali::WebEngine::EvaluateJavaScript()
113 void EvaluateJavaScript( const std::string& script );
116 * @copydoc Dali::WebEngine::AddJavaScriptInterface()
118 void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback );
121 * @copydoc Dali::WebEngine::RemoveJavascriptInterface()
123 void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName );
126 * @copydoc Dali::WebEngine::ClearHistory()
131 * @copydoc Dali::WebEngine::ClearCache()
136 * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
138 Dali::Toolkit::WebView::WebViewSignalType& PageLoadStartedSignal();
141 * @copydoc Dali::Toolkit::WebView::PageLoadFinishedSignal()
143 Dali::Toolkit::WebView::WebViewSignalType& PageLoadFinishedSignal();
145 public: // Properties
148 * @brief Called when a property of an object of this type is set.
150 * @param[in] object The object whose property is set.
151 * @param[in] index The property index.
152 * @param[in] value The new property value.
154 static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
157 * @brief Called to retrieve a property of an object of this type.
159 * @param[in] object The object whose property is to be retrieved.
160 * @param[in] index The property index.
161 * @return The current value of the property.
163 static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
166 * Connects a callback function with the object's signals.
167 * @param[in] object The object providing the signal.
168 * @param[in] tracker Used to disconnect the signal.
169 * @param[in] signalName The signal to connect to.
170 * @param[in] functor A newly allocated FunctorDelegate.
171 * @return True if the signal was connected.
172 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
174 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
176 private: // From Control
179 * @copydoc Toolkit::Control::OnInitialize()
181 virtual void OnInitialize();
184 * @copydoc Toolkit::Control::GetNaturalSize
186 virtual Vector3 GetNaturalSize();
189 * @copydoc Toolkit::Control::OnRelayout()
191 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
194 * Signal occurs when the Web View has been touched.
195 * @param[in] actor The Actor Touched
196 * @param[in] touch The Touch Data.
197 * @return Whether to consume event or not.
199 bool OnTouchEvent( Actor actor, const Dali::TouchData& touch );
202 * @copydoc Toolkit::Control::OnKeyEvent()
204 virtual bool OnKeyEvent( const Dali::KeyEvent& event );
209 WebView( const WebView& webView );
211 WebView& operator=( const WebView& webView );
213 void OnPageLoadStarted( const std::string& url );
215 void OnPageLoadFinished( const std::string& url );
220 Dali::Toolkit::Visual::Base mVisual;
221 Dali::Size mWebViewSize;
222 Dali::WebEngine mWebEngine;
223 Dali::Toolkit::WebView::WebViewSignalType mPageLoadStartedSignal;
224 Dali::Toolkit::WebView::WebViewSignalType mPageLoadFinishedSignal;
227 } // namespace Internal
229 inline Toolkit::Internal::WebView& GetImpl( Toolkit::WebView& handle )
231 DALI_ASSERT_ALWAYS( handle );
232 Dali::RefObject& impl = handle.GetImplementation();
233 return static_cast< Toolkit::Internal::WebView& >( impl );
236 inline const Toolkit::Internal::WebView& GetImpl( const Toolkit::WebView& handle )
238 DALI_ASSERT_ALWAYS( handle );
239 const Dali::RefObject& impl = handle.GetImplementation();
240 return static_cast< const Toolkit::Internal::WebView& >( impl );
243 } // namespace Toolkit
247 #endif // DALI_TOOLKIT_INTERNAL_WEB_VIEW_H