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-console-message.h>
24 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
30 #include <dali/internal/web-engine/common/web-engine-impl.h>
33 #include <dali/public-api/images/pixel-data.h>
37 WebEngine::WebEngine()
41 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
42 : BaseHandle(internal)
46 WebEngine::~WebEngine()
50 WebEngine WebEngine::New()
52 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
54 return WebEngine(engine.Get());
57 WebEngine::WebEngine(const WebEngine& webEngine)
58 : BaseHandle(webEngine)
62 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
64 if(*this != webEngine)
66 BaseHandle::operator=(webEngine);
71 WebEngine WebEngine::DownCast(BaseHandle handle)
73 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
76 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
78 GetImplementation(*this).Create(width, height, locale, timezoneId);
81 void WebEngine::Create(int width, int height, int argc, char** argv)
83 GetImplementation(*this).Create(width, height, argc, argv);
86 void WebEngine::Destroy()
88 GetImplementation(*this).Destroy();
91 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
93 return GetImplementation(*this).GetNativeImageSource();
96 Dali::WebEngineSettings& WebEngine::GetSettings() const
98 return GetImplementation(*this).GetSettings();
101 Dali::WebEngineContext& WebEngine::GetContext() const
103 return GetImplementation(*this).GetContext();
106 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
108 return GetImplementation(*this).GetCookieManager();
111 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
113 return GetImplementation(*this).GetBackForwardList();
116 void WebEngine::LoadUrl(const std::string& url)
118 return GetImplementation(*this).LoadUrl(url);
121 std::string WebEngine::GetTitle() const
123 return GetImplementation(*this).GetTitle();
126 Dali::PixelData WebEngine::GetFavicon() const
128 return GetImplementation(*this).GetFavicon();
131 const std::string& WebEngine::GetUrl()
133 return GetImplementation(*this).GetUrl();
136 void WebEngine::LoadHtmlString(const std::string& htmlString)
138 GetImplementation(*this).LoadHtmlString(htmlString);
141 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
143 return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
146 bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
148 return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
151 void WebEngine::Reload()
153 GetImplementation(*this).Reload();
156 bool WebEngine::ReloadWithoutCache()
158 return GetImplementation(*this).ReloadWithoutCache();
161 void WebEngine::StopLoading()
163 GetImplementation(*this).StopLoading();
166 void WebEngine::Suspend()
168 GetImplementation(*this).Suspend();
171 void WebEngine::Resume()
173 GetImplementation(*this).Resume();
176 void WebEngine::SuspendNetworkLoading()
178 GetImplementation(*this).SuspendNetworkLoading();
181 void WebEngine::ResumeNetworkLoading()
183 GetImplementation(*this).ResumeNetworkLoading();
186 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
188 return GetImplementation(*this).AddCustomHeader(name, value);
191 bool WebEngine::RemoveCustomHeader(const std::string& name)
193 return GetImplementation(*this).RemoveCustomHeader(name);
196 uint32_t WebEngine::StartInspectorServer(uint32_t port)
198 return GetImplementation(*this).StartInspectorServer(port);
201 bool WebEngine::StopInspectorServer()
203 return GetImplementation(*this).StopInspectorServer();
206 void WebEngine::ScrollBy(int deltaX, int deltaY)
208 GetImplementation(*this).ScrollBy(deltaX, deltaY);
211 bool WebEngine::ScrollEdgeBy(int deltaX, int deltaY)
213 return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
216 void WebEngine::SetScrollPosition(int x, int y)
218 GetImplementation(*this).SetScrollPosition(x, y);
221 Dali::Vector2 WebEngine::GetScrollPosition() const
223 return GetImplementation(*this).GetScrollPosition();
226 Dali::Vector2 WebEngine::GetScrollSize() const
228 return GetImplementation(*this).GetScrollSize();
231 Dali::Vector2 WebEngine::GetContentSize() const
233 return GetImplementation(*this).GetContentSize();
236 bool WebEngine::CanGoForward()
238 return GetImplementation(*this).CanGoForward();
241 void WebEngine::GoForward()
243 GetImplementation(*this).GoForward();
246 bool WebEngine::CanGoBack()
248 return GetImplementation(*this).CanGoBack();
251 void WebEngine::GoBack()
253 GetImplementation(*this).GoBack();
256 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
258 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
261 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
263 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
266 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
268 GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
271 void WebEngine::JavaScriptAlertReply()
273 GetImplementation(*this).JavaScriptAlertReply();
276 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
278 GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
281 void WebEngine::JavaScriptConfirmReply(bool confirmed)
283 GetImplementation(*this).JavaScriptConfirmReply(confirmed);
286 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
288 GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
291 void WebEngine::JavaScriptPromptReply(const std::string& result)
293 GetImplementation(*this).JavaScriptPromptReply(result);
296 void WebEngine::ClearHistory()
298 GetImplementation(*this).ClearHistory();
301 void WebEngine::ClearAllTilesResources()
303 GetImplementation(*this).ClearAllTilesResources();
306 const std::string& WebEngine::GetUserAgent() const
308 return GetImplementation(*this).GetUserAgent();
311 void WebEngine::SetUserAgent(const std::string& userAgent)
313 GetImplementation(*this).SetUserAgent(userAgent);
316 void WebEngine::SetSize(int width, int height)
318 GetImplementation(*this).SetSize(width, height);
321 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
323 GetImplementation(*this).SetDocumentBackgroundColor(color);
326 void WebEngine::ClearTilesWhenHidden(bool cleared)
328 GetImplementation(*this).ClearTilesWhenHidden(cleared);
331 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
333 GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
336 void WebEngine::EnableCursorByClient(bool enabled)
338 GetImplementation(*this).EnableCursorByClient(enabled);
341 std::string WebEngine::GetSelectedText() const
343 return GetImplementation(*this).GetSelectedText();
346 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
348 return GetImplementation(*this).SendTouchEvent(touch);
351 bool WebEngine::SendKeyEvent(const KeyEvent& event)
353 return GetImplementation(*this).SendKeyEvent(event);
356 bool WebEngine::SendHoverEvent( const HoverEvent& event )
358 return GetImplementation( *this ).SendHoverEvent( event );
361 bool WebEngine::SendWheelEvent( const WheelEvent& event )
363 return GetImplementation( *this ).SendWheelEvent( event );
366 void WebEngine::SetFocus(bool focused)
368 GetImplementation(*this).SetFocus(focused);
371 void WebEngine::SetPageZoomFactor(float zoomFactor)
373 GetImplementation(*this).SetPageZoomFactor(zoomFactor);
376 float WebEngine::GetPageZoomFactor() const
378 return GetImplementation(*this).GetPageZoomFactor();
381 void WebEngine::SetTextZoomFactor(float zoomFactor)
383 GetImplementation(*this).SetTextZoomFactor(zoomFactor);
386 float WebEngine::GetTextZoomFactor() const
388 return GetImplementation(*this).GetTextZoomFactor();
391 float WebEngine::GetLoadProgressPercentage() const
393 return GetImplementation(*this).GetLoadProgressPercentage();
396 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
398 GetImplementation(*this).SetScaleFactor(scaleFactor, point);
401 float WebEngine::GetScaleFactor() const
403 return GetImplementation(*this).GetScaleFactor();
406 void WebEngine::ActivateAccessibility(bool activated)
408 GetImplementation(*this).ActivateAccessibility(activated);
411 bool WebEngine::SetVisibility(bool visible)
413 return GetImplementation(*this).SetVisibility(visible);
416 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
418 return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
421 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
423 GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
426 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
428 return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
431 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
433 return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
436 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
438 return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
441 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
443 GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
446 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
448 GetImplementation(*this).UpdateDisplayArea(displayArea);
451 void WebEngine::EnableMouseEvents(bool enabled)
453 GetImplementation(*this).EnableMouseEvents(enabled);
456 void WebEngine::EnableKeyEvents(bool enabled)
458 GetImplementation(*this).EnableKeyEvents(enabled);
461 void WebEngine::EnableVideoHole(bool enabled)
463 GetImplementation(*this).EnableVideoHole(enabled);
466 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
468 return GetImplementation(*this).PageLoadStartedSignal();
471 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
473 return GetImplementation(*this).PageLoadInProgressSignal();
476 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
478 return GetImplementation(*this).PageLoadFinishedSignal();
481 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
483 return GetImplementation(*this).PageLoadErrorSignal();
486 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
488 return GetImplementation(*this).ScrollEdgeReachedSignal();
491 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
493 return GetImplementation(*this).UrlChangedSignal();
496 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
498 return GetImplementation(*this).FormRepostDecisionSignal();
501 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
503 return GetImplementation(*this).FrameRenderedSignal();
506 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
508 return GetImplementation(*this).RequestInterceptorSignal();
511 Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMessageSignal()
513 return GetImplementation(*this).ConsoleMessageSignal();
516 Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& WebEngine::PolicyDecisionSignal()
518 return GetImplementation(*this).PolicyDecisionSignal();