2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/devel-api/adaptor-framework/web-engine.h>
22 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
23 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
24 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
26 #include <dali/internal/web-engine/common/web-engine-impl.h>
29 #include <dali/public-api/images/pixel-data.h>
33 WebEngine::WebEngine()
37 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
38 : BaseHandle(internal)
42 WebEngine::~WebEngine()
46 WebEngine WebEngine::New()
48 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
50 return WebEngine(engine.Get());
53 WebEngine::WebEngine(const WebEngine& webEngine)
54 : BaseHandle(webEngine)
58 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
60 if(*this != webEngine)
62 BaseHandle::operator=(webEngine);
67 WebEngine WebEngine::DownCast(BaseHandle handle)
69 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
72 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
74 GetImplementation(*this).Create(width, height, locale, timezoneId);
77 void WebEngine::Create( int width, int height, int argc, char** argv )
79 GetImplementation( *this ).Create( width, height, argc, argv );
82 void WebEngine::Destroy()
84 GetImplementation(*this).Destroy();
87 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
89 return GetImplementation(*this).GetNativeImageSource();
92 Dali::WebEngineSettings& WebEngine::GetSettings() const
94 return GetImplementation( *this ).GetSettings();
97 Dali::WebEngineContext& WebEngine::GetContext() const
99 return GetImplementation( *this ).GetContext();
102 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
104 return GetImplementation( *this ).GetCookieManager();
107 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
109 return GetImplementation( *this ).GetBackForwardList();
112 void WebEngine::LoadUrl(const std::string& url)
114 return GetImplementation(*this).LoadUrl(url);
117 std::string WebEngine::GetTitle() const
119 return GetImplementation( *this ).GetTitle();
122 Dali::PixelData WebEngine::GetFavicon() const
124 return GetImplementation( *this ).GetFavicon();
127 const std::string& WebEngine::GetUrl()
129 return GetImplementation(*this).GetUrl();
132 void WebEngine::LoadHtmlString(const std::string& htmlString)
134 GetImplementation(*this).LoadHtmlString(htmlString);
137 void WebEngine::Reload()
139 GetImplementation(*this).Reload();
142 void WebEngine::StopLoading()
144 GetImplementation(*this).StopLoading();
147 void WebEngine::Suspend()
149 GetImplementation(*this).Suspend();
152 void WebEngine::Resume()
154 GetImplementation(*this).Resume();
157 void WebEngine::ScrollBy( int deltaX, int deltaY )
159 GetImplementation( *this ).ScrollBy( deltaX, deltaY );
162 void WebEngine::SetScrollPosition( int x, int y )
164 GetImplementation( *this ).SetScrollPosition( x, y );
167 Dali::Vector2 WebEngine::GetScrollPosition() const
169 return GetImplementation( *this ).GetScrollPosition();
172 Dali::Vector2 WebEngine::GetScrollSize() const
174 return GetImplementation( *this ).GetScrollSize();
177 Dali::Vector2 WebEngine::GetContentSize() const
179 return GetImplementation( *this ).GetContentSize();
182 bool WebEngine::CanGoForward()
184 return GetImplementation(*this).CanGoForward();
187 void WebEngine::GoForward()
189 GetImplementation(*this).GoForward();
192 bool WebEngine::CanGoBack()
194 return GetImplementation(*this).CanGoBack();
197 void WebEngine::GoBack()
199 GetImplementation(*this).GoBack();
202 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
204 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
207 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
209 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
212 void WebEngine::ClearAllTilesResources()
214 GetImplementation( *this ).ClearAllTilesResources();
217 void WebEngine::ClearHistory()
219 return GetImplementation(*this).ClearHistory();
222 const std::string& WebEngine::GetUserAgent() const
224 return GetImplementation(*this).GetUserAgent();
227 void WebEngine::SetUserAgent(const std::string& userAgent)
229 GetImplementation(*this).SetUserAgent(userAgent);
232 void WebEngine::SetSize(int width, int height)
234 return GetImplementation(*this).SetSize(width, height);
237 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
239 return GetImplementation(*this).SendTouchEvent(touch);
242 bool WebEngine::SendKeyEvent(const KeyEvent& event)
244 return GetImplementation(*this).SendKeyEvent(event);
247 void WebEngine::SetFocus( bool focused )
249 GetImplementation( *this ).SetFocus( focused );
252 void WebEngine::UpdateDisplayArea( Dali::Rect< int > displayArea )
254 GetImplementation( *this ).UpdateDisplayArea( displayArea );
257 void WebEngine::EnableVideoHole( bool enabled )
259 GetImplementation( *this ).EnableVideoHole( enabled );
262 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
264 return GetImplementation(*this).PageLoadStartedSignal();
267 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
269 return GetImplementation(*this).PageLoadFinishedSignal();
272 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
274 return GetImplementation(*this).PageLoadErrorSignal();
277 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
279 return GetImplementation( *this ).ScrollEdgeReachedSignal();