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-request-interceptor.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
29 #include <dali/internal/web-engine/common/web-engine-impl.h>
32 #include <dali/public-api/images/pixel-data.h>
36 WebEngine::WebEngine()
40 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
41 : BaseHandle(internal)
45 WebEngine::~WebEngine()
49 WebEngine WebEngine::New()
51 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
53 return WebEngine(engine.Get());
56 WebEngine::WebEngine(const WebEngine& webEngine)
57 : BaseHandle(webEngine)
61 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
63 if(*this != webEngine)
65 BaseHandle::operator=(webEngine);
70 WebEngine WebEngine::DownCast(BaseHandle handle)
72 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
75 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
77 GetImplementation(*this).Create(width, height, locale, timezoneId);
80 void WebEngine::Create(int width, int height, int argc, char** argv)
82 GetImplementation(*this).Create(width, height, argc, argv);
85 void WebEngine::Destroy()
87 GetImplementation(*this).Destroy();
90 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
92 return GetImplementation(*this).GetNativeImageSource();
95 Dali::WebEngineSettings& WebEngine::GetSettings() const
97 return GetImplementation(*this).GetSettings();
100 Dali::WebEngineContext& WebEngine::GetContext() const
102 return GetImplementation(*this).GetContext();
105 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
107 return GetImplementation(*this).GetCookieManager();
110 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
112 return GetImplementation(*this).GetBackForwardList();
115 void WebEngine::LoadUrl(const std::string& url)
117 return GetImplementation(*this).LoadUrl(url);
120 std::string WebEngine::GetTitle() const
122 return GetImplementation(*this).GetTitle();
125 Dali::PixelData WebEngine::GetFavicon() const
127 return GetImplementation(*this).GetFavicon();
130 const std::string& WebEngine::GetUrl()
132 return GetImplementation(*this).GetUrl();
135 void WebEngine::LoadHtmlString(const std::string& htmlString)
137 GetImplementation(*this).LoadHtmlString(htmlString);
140 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
142 return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
145 bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
147 return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
150 void WebEngine::Reload()
152 GetImplementation(*this).Reload();
155 bool WebEngine::ReloadWithoutCache()
157 return GetImplementation(*this).ReloadWithoutCache();
160 void WebEngine::StopLoading()
162 GetImplementation(*this).StopLoading();
165 void WebEngine::Suspend()
167 GetImplementation(*this).Suspend();
170 void WebEngine::Resume()
172 GetImplementation(*this).Resume();
175 void WebEngine::SuspendNetworkLoading()
177 GetImplementation(*this).SuspendNetworkLoading();
180 void WebEngine::ResumeNetworkLoading()
182 GetImplementation(*this).ResumeNetworkLoading();
185 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
187 return GetImplementation(*this).AddCustomHeader(name, value);
190 bool WebEngine::RemoveCustomHeader(const std::string& name)
192 return GetImplementation(*this).RemoveCustomHeader(name);
195 uint32_t WebEngine::StartInspectorServer(uint32_t port)
197 return GetImplementation(*this).StartInspectorServer(port);
200 bool WebEngine::StopInspectorServer()
202 return GetImplementation(*this).StopInspectorServer();
205 void WebEngine::ScrollBy(int deltaX, int deltaY)
207 GetImplementation(*this).ScrollBy(deltaX, deltaY);
210 bool WebEngine::ScrollEdgeBy(int deltaX, int deltaY)
212 return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
215 void WebEngine::SetScrollPosition(int x, int y)
217 GetImplementation(*this).SetScrollPosition(x, y);
220 Dali::Vector2 WebEngine::GetScrollPosition() const
222 return GetImplementation(*this).GetScrollPosition();
225 Dali::Vector2 WebEngine::GetScrollSize() const
227 return GetImplementation(*this).GetScrollSize();
230 Dali::Vector2 WebEngine::GetContentSize() const
232 return GetImplementation(*this).GetContentSize();
235 bool WebEngine::CanGoForward()
237 return GetImplementation(*this).CanGoForward();
240 void WebEngine::GoForward()
242 GetImplementation(*this).GoForward();
245 bool WebEngine::CanGoBack()
247 return GetImplementation(*this).CanGoBack();
250 void WebEngine::GoBack()
252 GetImplementation(*this).GoBack();
255 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
257 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
260 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
262 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
265 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
267 GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
270 void WebEngine::JavaScriptAlertReply()
272 GetImplementation(*this).JavaScriptAlertReply();
275 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
277 GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
280 void WebEngine::JavaScriptConfirmReply(bool confirmed)
282 GetImplementation(*this).JavaScriptConfirmReply(confirmed);
285 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
287 GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
290 void WebEngine::JavaScriptPromptReply(const std::string& result)
292 GetImplementation(*this).JavaScriptPromptReply(result);
295 void WebEngine::ClearHistory()
297 GetImplementation(*this).ClearHistory();
300 void WebEngine::ClearAllTilesResources()
302 GetImplementation(*this).ClearAllTilesResources();
305 const std::string& WebEngine::GetUserAgent() const
307 return GetImplementation(*this).GetUserAgent();
310 void WebEngine::SetUserAgent(const std::string& userAgent)
312 GetImplementation(*this).SetUserAgent(userAgent);
315 void WebEngine::SetSize(int width, int height)
317 GetImplementation(*this).SetSize(width, height);
320 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
322 GetImplementation(*this).SetDocumentBackgroundColor(color);
325 void WebEngine::ClearTilesWhenHidden(bool cleared)
327 GetImplementation(*this).ClearTilesWhenHidden(cleared);
330 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
332 GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
335 void WebEngine::EnableCursorByClient(bool enabled)
337 GetImplementation(*this).EnableCursorByClient(enabled);
340 std::string WebEngine::GetSelectedText() const
342 return GetImplementation(*this).GetSelectedText();
345 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
347 return GetImplementation(*this).SendTouchEvent(touch);
350 bool WebEngine::SendKeyEvent(const KeyEvent& event)
352 return GetImplementation(*this).SendKeyEvent(event);
355 bool WebEngine::SendHoverEvent( const HoverEvent& event )
357 return GetImplementation( *this ).SendHoverEvent( event );
360 bool WebEngine::SendWheelEvent( const WheelEvent& event )
362 return GetImplementation( *this ).SendWheelEvent( event );
365 void WebEngine::SetFocus(bool focused)
367 GetImplementation(*this).SetFocus(focused);
370 void WebEngine::SetPageZoomFactor(float zoomFactor)
372 GetImplementation(*this).SetPageZoomFactor(zoomFactor);
375 float WebEngine::GetPageZoomFactor() const
377 return GetImplementation(*this).GetPageZoomFactor();
380 void WebEngine::SetTextZoomFactor(float zoomFactor)
382 GetImplementation(*this).SetTextZoomFactor(zoomFactor);
385 float WebEngine::GetTextZoomFactor() const
387 return GetImplementation(*this).GetTextZoomFactor();
390 float WebEngine::GetLoadProgressPercentage() const
392 return GetImplementation(*this).GetLoadProgressPercentage();
395 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
397 GetImplementation(*this).SetScaleFactor(scaleFactor, point);
400 float WebEngine::GetScaleFactor() const
402 return GetImplementation(*this).GetScaleFactor();
405 void WebEngine::ActivateAccessibility(bool activated)
407 GetImplementation(*this).ActivateAccessibility(activated);
410 bool WebEngine::SetVisibility(bool visible)
412 return GetImplementation(*this).SetVisibility(visible);
415 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
417 return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
420 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
422 GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
425 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
427 return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
430 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
432 return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
435 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
437 return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
440 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
442 GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
445 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
447 GetImplementation(*this).UpdateDisplayArea(displayArea);
450 void WebEngine::EnableMouseEvents(bool enabled)
452 GetImplementation(*this).EnableMouseEvents(enabled);
455 void WebEngine::EnableKeyEvents(bool enabled)
457 GetImplementation(*this).EnableKeyEvents(enabled);
460 void WebEngine::EnableVideoHole(bool enabled)
462 GetImplementation(*this).EnableVideoHole(enabled);
465 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
467 return GetImplementation(*this).PageLoadStartedSignal();
470 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
472 return GetImplementation(*this).PageLoadInProgressSignal();
475 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
477 return GetImplementation(*this).PageLoadFinishedSignal();
480 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
482 return GetImplementation(*this).PageLoadErrorSignal();
485 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
487 return GetImplementation(*this).ScrollEdgeReachedSignal();
490 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
492 return GetImplementation(*this).UrlChangedSignal();
495 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
497 return GetImplementation(*this).FormRepostDecisionSignal();
500 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
502 return GetImplementation(*this).FrameRenderedSignal();
505 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
507 return GetImplementation(*this).RequestInterceptorSignal();
510 Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMessageSignal()
512 return GetImplementation(*this).ConsoleMessageSignal();