2 * Copyright (c) 2021 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::RegisterJavaScriptAlertCallback( Dali::WebEnginePlugin::JavaScriptAlertCallback callback )
214 GetImplementation( *this ).RegisterJavaScriptAlertCallback( callback );
217 void WebEngine::JavaScriptAlertReply()
219 GetImplementation( *this ).JavaScriptAlertReply();
222 void WebEngine::RegisterJavaScriptConfirmCallback( Dali::WebEnginePlugin::JavaScriptConfirmCallback callback )
224 GetImplementation( *this ).RegisterJavaScriptConfirmCallback( callback );
227 void WebEngine::JavaScriptConfirmReply( bool confirmed )
229 GetImplementation( *this ).JavaScriptConfirmReply( confirmed );
232 void WebEngine::RegisterJavaScriptPromptCallback( Dali::WebEnginePlugin::JavaScriptPromptCallback callback )
234 GetImplementation( *this ).RegisterJavaScriptPromptCallback( callback );
237 void WebEngine::JavaScriptPromptReply( const std::string& result )
239 GetImplementation( *this ).JavaScriptPromptReply( result );
242 void WebEngine::ClearHistory()
244 return GetImplementation(*this).ClearHistory();
247 void WebEngine::ClearAllTilesResources()
249 GetImplementation( *this ).ClearAllTilesResources();
252 const std::string& WebEngine::GetUserAgent() const
254 return GetImplementation(*this).GetUserAgent();
257 void WebEngine::SetUserAgent(const std::string& userAgent)
259 GetImplementation(*this).SetUserAgent(userAgent);
262 void WebEngine::SetSize(int width, int height)
264 return GetImplementation(*this).SetSize(width, height);
267 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
269 return GetImplementation(*this).SendTouchEvent(touch);
272 bool WebEngine::SendKeyEvent(const KeyEvent& event)
274 return GetImplementation(*this).SendKeyEvent(event);
277 bool WebEngine::SendHoverEvent( const HoverEvent& event )
279 return GetImplementation( *this ).SendHoverEvent( event );
282 bool WebEngine::SendWheelEvent( const WheelEvent& event )
284 return GetImplementation( *this ).SendWheelEvent( event );
287 void WebEngine::SetFocus(bool focused)
289 GetImplementation(*this).SetFocus(focused);
292 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
294 GetImplementation(*this).UpdateDisplayArea(displayArea);
297 void WebEngine::EnableMouseEvents(bool enabled)
299 GetImplementation(*this).EnableMouseEvents(enabled);
302 void WebEngine::EnableKeyEvents(bool enabled)
304 GetImplementation(*this).EnableKeyEvents(enabled);
307 void WebEngine::EnableVideoHole(bool enabled)
309 GetImplementation(*this).EnableVideoHole(enabled);
312 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
314 return GetImplementation(*this).PageLoadStartedSignal();
317 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
319 return GetImplementation(*this).PageLoadInProgressSignal();
322 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
324 return GetImplementation(*this).PageLoadFinishedSignal();
327 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
329 return GetImplementation(*this).PageLoadErrorSignal();
332 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
334 return GetImplementation(*this).ScrollEdgeReachedSignal();
337 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
339 return GetImplementation(*this).UrlChangedSignal();