2 * Copyright (c) 2024 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/web-engine.h>
22 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-back-forward-list.h>
23 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-certificate.h>
24 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-console-message.h>
25 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-context-menu-item.h>
26 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-context-menu.h>
27 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-context.h>
28 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-cookie-manager.h>
29 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-http-auth-handler.h>
30 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-load-error.h>
31 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-policy-decision.h>
32 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-settings.h>
33 #include <dali/internal/web-engine/common/web-engine-impl.h>
36 #include <dali/public-api/images/pixel-data.h>
40 WebEngine::WebEngine()
44 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
45 : BaseHandle(internal)
49 WebEngine::~WebEngine()
53 WebEngine WebEngine::New()
55 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
57 return WebEngine(engine.Get());
60 Dali::WebEngineContext* WebEngine::GetContext()
62 return Internal::Adaptor::WebEngine::GetContext();
65 Dali::WebEngineCookieManager* WebEngine::GetCookieManager()
67 return Internal::Adaptor::WebEngine::GetCookieManager();
70 WebEngine::WebEngine(const WebEngine& webEngine) = default;
72 WebEngine& WebEngine::operator=(const WebEngine& webEngine) = default;
74 WebEngine::WebEngine(WebEngine&& webEngine) = default;
76 WebEngine& WebEngine::operator=(WebEngine&& webEngine) = default;
78 WebEngine WebEngine::DownCast(BaseHandle handle)
80 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
83 void WebEngine::Create(uint32_t width, uint32_t height, const std::string& locale, const std::string& timezoneId)
85 GetImplementation(*this).Create(width, height, locale, timezoneId);
88 void WebEngine::Create(uint32_t width, uint32_t height, uint32_t argc, char** argv)
90 GetImplementation(*this).Create(width, height, argc, argv);
93 void WebEngine::Destroy()
95 GetImplementation(*this).Destroy();
98 Dali::WebEnginePlugin* WebEngine::GetPlugin() const
100 return GetImplementation(*this).GetPlugin();
103 NativeImageSourcePtr WebEngine::GetNativeImageSource()
105 return GetImplementation(*this).GetNativeImageSource();
108 void WebEngine::ChangeOrientation(int orientation)
110 return GetImplementation(*this).ChangeOrientation(orientation);
113 Dali::WebEngineSettings& WebEngine::GetSettings() const
115 return GetImplementation(*this).GetSettings();
118 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
120 return GetImplementation(*this).GetBackForwardList();
123 void WebEngine::LoadUrl(const std::string& url)
125 return GetImplementation(*this).LoadUrl(url);
128 std::string WebEngine::GetTitle() const
130 return GetImplementation(*this).GetTitle();
133 Dali::PixelData WebEngine::GetFavicon() const
135 return GetImplementation(*this).GetFavicon();
138 std::string WebEngine::GetUrl() const
140 return GetImplementation(*this).GetUrl();
143 void WebEngine::LoadHtmlString(const std::string& htmlString)
145 GetImplementation(*this).LoadHtmlString(htmlString);
148 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
150 return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
153 bool WebEngine::LoadContents(const int8_t* contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
155 return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
158 void WebEngine::Reload()
160 GetImplementation(*this).Reload();
163 bool WebEngine::ReloadWithoutCache()
165 return GetImplementation(*this).ReloadWithoutCache();
168 void WebEngine::StopLoading()
170 GetImplementation(*this).StopLoading();
173 void WebEngine::Suspend()
175 GetImplementation(*this).Suspend();
178 void WebEngine::Resume()
180 GetImplementation(*this).Resume();
183 void WebEngine::SuspendNetworkLoading()
185 GetImplementation(*this).SuspendNetworkLoading();
188 void WebEngine::ResumeNetworkLoading()
190 GetImplementation(*this).ResumeNetworkLoading();
193 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
195 return GetImplementation(*this).AddCustomHeader(name, value);
198 bool WebEngine::RemoveCustomHeader(const std::string& name)
200 return GetImplementation(*this).RemoveCustomHeader(name);
203 uint32_t WebEngine::StartInspectorServer(uint32_t port)
205 return GetImplementation(*this).StartInspectorServer(port);
208 bool WebEngine::StopInspectorServer()
210 return GetImplementation(*this).StopInspectorServer();
213 void WebEngine::ScrollBy(int32_t deltaX, int32_t deltaY)
215 GetImplementation(*this).ScrollBy(deltaX, deltaY);
218 bool WebEngine::ScrollEdgeBy(int32_t deltaX, int32_t deltaY)
220 return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
223 void WebEngine::SetScrollPosition(int32_t x, int32_t y)
225 GetImplementation(*this).SetScrollPosition(x, y);
228 Dali::Vector2 WebEngine::GetScrollPosition() const
230 return GetImplementation(*this).GetScrollPosition();
233 Dali::Vector2 WebEngine::GetScrollSize() const
235 return GetImplementation(*this).GetScrollSize();
238 Dali::Vector2 WebEngine::GetContentSize() const
240 return GetImplementation(*this).GetContentSize();
243 bool WebEngine::CanGoForward()
245 return GetImplementation(*this).CanGoForward();
248 void WebEngine::GoForward()
250 GetImplementation(*this).GoForward();
253 bool WebEngine::CanGoBack()
255 return GetImplementation(*this).CanGoBack();
258 void WebEngine::GoBack()
260 GetImplementation(*this).GoBack();
263 void WebEngine::EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler)
265 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
268 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler)
270 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
273 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
275 GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
278 void WebEngine::JavaScriptAlertReply()
280 GetImplementation(*this).JavaScriptAlertReply();
283 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
285 GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
288 void WebEngine::JavaScriptConfirmReply(bool confirmed)
290 GetImplementation(*this).JavaScriptConfirmReply(confirmed);
293 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
295 GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
298 void WebEngine::JavaScriptPromptReply(const std::string& result)
300 GetImplementation(*this).JavaScriptPromptReply(result);
303 std::unique_ptr<Dali::WebEngineHitTest> WebEngine::CreateHitTest(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode)
305 return GetImplementation(*this).CreateHitTest(x, y, mode);
308 bool WebEngine::CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode, Dali::WebEnginePlugin::WebEngineHitTestCreatedCallback callback)
310 return GetImplementation(*this).CreateHitTestAsynchronously(x, y, mode, callback);
313 void WebEngine::ClearHistory()
315 GetImplementation(*this).ClearHistory();
318 void WebEngine::ClearAllTilesResources()
320 GetImplementation(*this).ClearAllTilesResources();
323 std::string WebEngine::GetUserAgent() const
325 return GetImplementation(*this).GetUserAgent();
328 void WebEngine::SetUserAgent(const std::string& userAgent)
330 GetImplementation(*this).SetUserAgent(userAgent);
333 void WebEngine::SetSize(uint32_t width, uint32_t height)
335 GetImplementation(*this).SetSize(width, height);
338 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
340 GetImplementation(*this).SetDocumentBackgroundColor(color);
343 void WebEngine::ClearTilesWhenHidden(bool cleared)
345 GetImplementation(*this).ClearTilesWhenHidden(cleared);
348 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
350 GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
353 void WebEngine::EnableCursorByClient(bool enabled)
355 GetImplementation(*this).EnableCursorByClient(enabled);
358 std::string WebEngine::GetSelectedText() const
360 return GetImplementation(*this).GetSelectedText();
363 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
365 return GetImplementation(*this).SendTouchEvent(touch);
368 bool WebEngine::SendKeyEvent(const KeyEvent& event)
370 return GetImplementation(*this).SendKeyEvent(event);
373 bool WebEngine::SendHoverEvent(const HoverEvent& event)
375 return GetImplementation(*this).SendHoverEvent(event);
378 bool WebEngine::SendWheelEvent(const WheelEvent& event)
380 return GetImplementation(*this).SendWheelEvent(event);
383 void WebEngine::ExitFullscreen()
385 GetImplementation(*this).ExitFullscreen();
388 void WebEngine::SetFocus(bool focused)
390 GetImplementation(*this).SetFocus(focused);
393 void WebEngine::SetPageZoomFactor(float zoomFactor)
395 GetImplementation(*this).SetPageZoomFactor(zoomFactor);
398 float WebEngine::GetPageZoomFactor() const
400 return GetImplementation(*this).GetPageZoomFactor();
403 void WebEngine::SetTextZoomFactor(float zoomFactor)
405 GetImplementation(*this).SetTextZoomFactor(zoomFactor);
408 float WebEngine::GetTextZoomFactor() const
410 return GetImplementation(*this).GetTextZoomFactor();
413 float WebEngine::GetLoadProgressPercentage() const
415 return GetImplementation(*this).GetLoadProgressPercentage();
418 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
420 GetImplementation(*this).SetScaleFactor(scaleFactor, point);
423 float WebEngine::GetScaleFactor() const
425 return GetImplementation(*this).GetScaleFactor();
428 void WebEngine::ActivateAccessibility(bool activated)
430 GetImplementation(*this).ActivateAccessibility(activated);
433 Accessibility::Address WebEngine::GetAccessibilityAddress()
435 return GetImplementation(*this).GetAccessibilityAddress();
438 bool WebEngine::SetVisibility(bool visible)
440 return GetImplementation(*this).SetVisibility(visible);
443 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
445 return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
448 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
450 GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
453 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int32_t> viewArea, float scaleFactor)
455 return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
458 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int32_t> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
460 return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
463 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
465 return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
468 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
470 GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
473 void WebEngine::UpdateDisplayArea(Dali::Rect<int32_t> displayArea)
475 GetImplementation(*this).UpdateDisplayArea(displayArea);
478 void WebEngine::EnableMouseEvents(bool enabled)
480 GetImplementation(*this).EnableMouseEvents(enabled);
483 void WebEngine::EnableKeyEvents(bool enabled)
485 GetImplementation(*this).EnableKeyEvents(enabled);
488 void WebEngine::EnableVideoHole(bool enabled)
490 GetImplementation(*this).EnableVideoHole(enabled);
493 void WebEngine::RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback)
495 GetImplementation(*this).RegisterFrameRenderedCallback(callback);
498 void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
500 GetImplementation(*this).RegisterPageLoadStartedCallback(callback);
503 void WebEngine::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
505 GetImplementation(*this).RegisterPageLoadInProgressCallback(callback);
508 void WebEngine::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
510 GetImplementation(*this).RegisterPageLoadFinishedCallback(callback);
513 void WebEngine::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback)
515 GetImplementation(*this).RegisterPageLoadErrorCallback(callback);
518 void WebEngine::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback)
520 GetImplementation(*this).RegisterScrollEdgeReachedCallback(callback);
523 void WebEngine::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback)
525 GetImplementation(*this).RegisterUrlChangedCallback(callback);
528 void WebEngine::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback)
530 GetImplementation(*this).RegisterFormRepostDecidedCallback(callback);
533 void WebEngine::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
535 GetImplementation(*this).RegisterConsoleMessageReceivedCallback(callback);
538 void WebEngine::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback)
540 GetImplementation(*this).RegisterResponsePolicyDecidedCallback(callback);
543 void WebEngine::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback)
545 GetImplementation(*this).RegisterNavigationPolicyDecidedCallback(callback);
548 void WebEngine::RegisterNewWindowPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNewWindowPolicyDecidedCallback callback)
550 GetImplementation(*this).RegisterNewWindowPolicyDecidedCallback(callback);
553 void WebEngine::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
555 GetImplementation(*this).RegisterNewWindowCreatedCallback(callback);
558 void WebEngine::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
560 GetImplementation(*this).RegisterCertificateConfirmedCallback(callback);
563 void WebEngine::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
565 GetImplementation(*this).RegisterSslCertificateChangedCallback(callback);
568 void WebEngine::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback)
570 GetImplementation(*this).RegisterHttpAuthHandlerCallback(callback);
573 void WebEngine::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback)
575 GetImplementation(*this).RegisterContextMenuShownCallback(callback);
578 void WebEngine::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback)
580 GetImplementation(*this).RegisterContextMenuHiddenCallback(callback);
583 void WebEngine::RegisterFullscreenEnteredCallback(Dali::WebEnginePlugin::WebEngineFullscreenEnteredCallback callback)
585 GetImplementation(*this).RegisterFullscreenEnteredCallback(callback);
588 void WebEngine::RegisterFullscreenExitedCallback(Dali::WebEnginePlugin::WebEngineFullscreenExitedCallback callback)
590 GetImplementation(*this).RegisterFullscreenExitedCallback(callback);
593 void WebEngine::RegisterTextFoundCallback(Dali::WebEnginePlugin::WebEngineTextFoundCallback callback)
595 GetImplementation(*this).RegisterTextFoundCallback(callback);
598 void WebEngine::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
600 GetImplementation(*this).GetPlainTextAsynchronously(callback);