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::AddJavaScriptMessageHandler()
118 void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler );
121 * @copydoc Dali::WebEngine::ClearHistory()
126 * @copydoc Dali::WebEngine::ClearCache()
131 * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
133 Dali::Toolkit::WebView::WebViewSignalType& PageLoadStartedSignal();
136 * @copydoc Dali::Toolkit::WebView::PageLoadFinishedSignal()
138 Dali::Toolkit::WebView::WebViewSignalType& PageLoadFinishedSignal();
140 public: // Properties
143 * @brief Called when a property of an object of this type is set.
145 * @param[in] object The object whose property is set.
146 * @param[in] index The property index.
147 * @param[in] value The new property value.
149 static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
152 * @brief Called to retrieve a property of an object of this type.
154 * @param[in] object The object whose property is to be retrieved.
155 * @param[in] index The property index.
156 * @return The current value of the property.
158 static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
161 * Connects a callback function with the object's signals.
162 * @param[in] object The object providing the signal.
163 * @param[in] tracker Used to disconnect the signal.
164 * @param[in] signalName The signal to connect to.
165 * @param[in] functor A newly allocated FunctorDelegate.
166 * @return True if the signal was connected.
167 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
169 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
171 private: // From Control
174 * @copydoc Toolkit::Control::OnInitialize()
176 virtual void OnInitialize();
179 * @copydoc Toolkit::Control::GetNaturalSize
181 virtual Vector3 GetNaturalSize();
184 * @copydoc Toolkit::Control::OnRelayout()
186 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
189 * Signal occurs when the Web View has been touched.
190 * @param[in] actor The Actor Touched
191 * @param[in] touch The Touch Data.
192 * @return Whether to consume event or not.
194 bool OnTouchEvent( Actor actor, const Dali::TouchData& touch );
197 * @copydoc Toolkit::Control::OnKeyEvent()
199 virtual bool OnKeyEvent( const Dali::KeyEvent& event );
204 WebView( const WebView& webView );
206 WebView& operator=( const WebView& webView );
208 void OnPageLoadStarted( const std::string& url );
210 void OnPageLoadFinished( const std::string& url );
215 Dali::Toolkit::Visual::Base mVisual;
216 Dali::Size mWebViewSize;
217 Dali::WebEngine mWebEngine;
218 Dali::Toolkit::WebView::WebViewSignalType mPageLoadStartedSignal;
219 Dali::Toolkit::WebView::WebViewSignalType mPageLoadFinishedSignal;
222 } // namespace Internal
224 inline Toolkit::Internal::WebView& GetImpl( Toolkit::WebView& handle )
226 DALI_ASSERT_ALWAYS( handle );
227 Dali::RefObject& impl = handle.GetImplementation();
228 return static_cast< Toolkit::Internal::WebView& >( impl );
231 inline const Toolkit::Internal::WebView& GetImpl( const Toolkit::WebView& handle )
233 DALI_ASSERT_ALWAYS( handle );
234 const Dali::RefObject& impl = handle.GetImplementation();
235 return static_cast< const Toolkit::Internal::WebView& >( impl );
238 } // namespace Toolkit
242 #endif // DALI_TOOLKIT_INTERNAL_WEB_VIEW_H