2 * Copyright (c) 2023 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 Dali::WebEngineSettings& WebEngine::GetSettings() const
110 return GetImplementation(*this).GetSettings();
113 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
115 return GetImplementation(*this).GetBackForwardList();
118 void WebEngine::LoadUrl(const std::string& url)
120 return GetImplementation(*this).LoadUrl(url);
123 std::string WebEngine::GetTitle() const
125 return GetImplementation(*this).GetTitle();
128 Dali::PixelData WebEngine::GetFavicon() const
130 return GetImplementation(*this).GetFavicon();
133 std::string WebEngine::GetUrl() const
135 return GetImplementation(*this).GetUrl();
138 void WebEngine::LoadHtmlString(const std::string& htmlString)
140 GetImplementation(*this).LoadHtmlString(htmlString);
143 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
145 return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
148 bool WebEngine::LoadContents(const int8_t* contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
150 return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
153 void WebEngine::Reload()
155 GetImplementation(*this).Reload();
158 bool WebEngine::ReloadWithoutCache()
160 return GetImplementation(*this).ReloadWithoutCache();
163 void WebEngine::StopLoading()
165 GetImplementation(*this).StopLoading();
168 void WebEngine::Suspend()
170 GetImplementation(*this).Suspend();
173 void WebEngine::Resume()
175 GetImplementation(*this).Resume();
178 void WebEngine::SuspendNetworkLoading()
180 GetImplementation(*this).SuspendNetworkLoading();
183 void WebEngine::ResumeNetworkLoading()
185 GetImplementation(*this).ResumeNetworkLoading();
188 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
190 return GetImplementation(*this).AddCustomHeader(name, value);
193 bool WebEngine::RemoveCustomHeader(const std::string& name)
195 return GetImplementation(*this).RemoveCustomHeader(name);
198 uint32_t WebEngine::StartInspectorServer(uint32_t port)
200 return GetImplementation(*this).StartInspectorServer(port);
203 bool WebEngine::StopInspectorServer()
205 return GetImplementation(*this).StopInspectorServer();
208 void WebEngine::ScrollBy(int32_t deltaX, int32_t deltaY)
210 GetImplementation(*this).ScrollBy(deltaX, deltaY);
213 bool WebEngine::ScrollEdgeBy(int32_t deltaX, int32_t deltaY)
215 return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
218 void WebEngine::SetScrollPosition(int32_t x, int32_t y)
220 GetImplementation(*this).SetScrollPosition(x, y);
223 Dali::Vector2 WebEngine::GetScrollPosition() const
225 return GetImplementation(*this).GetScrollPosition();
228 Dali::Vector2 WebEngine::GetScrollSize() const
230 return GetImplementation(*this).GetScrollSize();
233 Dali::Vector2 WebEngine::GetContentSize() const
235 return GetImplementation(*this).GetContentSize();
238 bool WebEngine::CanGoForward()
240 return GetImplementation(*this).CanGoForward();
243 void WebEngine::GoForward()
245 GetImplementation(*this).GoForward();
248 bool WebEngine::CanGoBack()
250 return GetImplementation(*this).CanGoBack();
253 void WebEngine::GoBack()
255 GetImplementation(*this).GoBack();
258 void WebEngine::EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler)
260 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
263 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler)
265 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
268 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
270 GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
273 void WebEngine::JavaScriptAlertReply()
275 GetImplementation(*this).JavaScriptAlertReply();
278 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
280 GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
283 void WebEngine::JavaScriptConfirmReply(bool confirmed)
285 GetImplementation(*this).JavaScriptConfirmReply(confirmed);
288 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
290 GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
293 void WebEngine::JavaScriptPromptReply(const std::string& result)
295 GetImplementation(*this).JavaScriptPromptReply(result);
298 std::unique_ptr<Dali::WebEngineHitTest> WebEngine::CreateHitTest(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode)
300 return GetImplementation(*this).CreateHitTest(x, y, mode);
303 bool WebEngine::CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode, Dali::WebEnginePlugin::WebEngineHitTestCreatedCallback callback)
305 return GetImplementation(*this).CreateHitTestAsynchronously(x, y, mode, callback);
308 void WebEngine::ClearHistory()
310 GetImplementation(*this).ClearHistory();
313 void WebEngine::ClearAllTilesResources()
315 GetImplementation(*this).ClearAllTilesResources();
318 std::string WebEngine::GetUserAgent() const
320 return GetImplementation(*this).GetUserAgent();
323 void WebEngine::SetUserAgent(const std::string& userAgent)
325 GetImplementation(*this).SetUserAgent(userAgent);
328 void WebEngine::SetSize(uint32_t width, uint32_t height)
330 GetImplementation(*this).SetSize(width, height);
333 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
335 GetImplementation(*this).SetDocumentBackgroundColor(color);
338 void WebEngine::ClearTilesWhenHidden(bool cleared)
340 GetImplementation(*this).ClearTilesWhenHidden(cleared);
343 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
345 GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
348 void WebEngine::EnableCursorByClient(bool enabled)
350 GetImplementation(*this).EnableCursorByClient(enabled);
353 std::string WebEngine::GetSelectedText() const
355 return GetImplementation(*this).GetSelectedText();
358 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
360 return GetImplementation(*this).SendTouchEvent(touch);
363 bool WebEngine::SendKeyEvent(const KeyEvent& event)
365 return GetImplementation(*this).SendKeyEvent(event);
368 bool WebEngine::SendHoverEvent(const HoverEvent& event)
370 return GetImplementation(*this).SendHoverEvent(event);
373 bool WebEngine::SendWheelEvent(const WheelEvent& event)
375 return GetImplementation(*this).SendWheelEvent(event);
378 void WebEngine::SetFocus(bool focused)
380 GetImplementation(*this).SetFocus(focused);
383 void WebEngine::SetPageZoomFactor(float zoomFactor)
385 GetImplementation(*this).SetPageZoomFactor(zoomFactor);
388 float WebEngine::GetPageZoomFactor() const
390 return GetImplementation(*this).GetPageZoomFactor();
393 void WebEngine::SetTextZoomFactor(float zoomFactor)
395 GetImplementation(*this).SetTextZoomFactor(zoomFactor);
398 float WebEngine::GetTextZoomFactor() const
400 return GetImplementation(*this).GetTextZoomFactor();
403 float WebEngine::GetLoadProgressPercentage() const
405 return GetImplementation(*this).GetLoadProgressPercentage();
408 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
410 GetImplementation(*this).SetScaleFactor(scaleFactor, point);
413 float WebEngine::GetScaleFactor() const
415 return GetImplementation(*this).GetScaleFactor();
418 void WebEngine::ActivateAccessibility(bool activated)
420 GetImplementation(*this).ActivateAccessibility(activated);
423 Accessibility::Address WebEngine::GetAccessibilityAddress()
425 return GetImplementation(*this).GetAccessibilityAddress();
428 bool WebEngine::SetVisibility(bool visible)
430 return GetImplementation(*this).SetVisibility(visible);
433 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
435 return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
438 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
440 GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
443 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int32_t> viewArea, float scaleFactor)
445 return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
448 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int32_t> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
450 return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
453 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
455 return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
458 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
460 GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
463 void WebEngine::UpdateDisplayArea(Dali::Rect<int32_t> displayArea)
465 GetImplementation(*this).UpdateDisplayArea(displayArea);
468 void WebEngine::EnableMouseEvents(bool enabled)
470 GetImplementation(*this).EnableMouseEvents(enabled);
473 void WebEngine::EnableKeyEvents(bool enabled)
475 GetImplementation(*this).EnableKeyEvents(enabled);
478 void WebEngine::EnableVideoHole(bool enabled)
480 GetImplementation(*this).EnableVideoHole(enabled);
483 void WebEngine::RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback)
485 GetImplementation(*this).RegisterFrameRenderedCallback(callback);
488 void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
490 GetImplementation(*this).RegisterPageLoadStartedCallback(callback);
493 void WebEngine::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
495 GetImplementation(*this).RegisterPageLoadInProgressCallback(callback);
498 void WebEngine::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
500 GetImplementation(*this).RegisterPageLoadFinishedCallback(callback);
503 void WebEngine::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback)
505 GetImplementation(*this).RegisterPageLoadErrorCallback(callback);
508 void WebEngine::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback)
510 GetImplementation(*this).RegisterScrollEdgeReachedCallback(callback);
513 void WebEngine::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback)
515 GetImplementation(*this).RegisterUrlChangedCallback(callback);
518 void WebEngine::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback)
520 GetImplementation(*this).RegisterFormRepostDecidedCallback(callback);
523 void WebEngine::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
525 GetImplementation(*this).RegisterConsoleMessageReceivedCallback(callback);
528 void WebEngine::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback)
530 GetImplementation(*this).RegisterResponsePolicyDecidedCallback(callback);
533 void WebEngine::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback)
535 GetImplementation(*this).RegisterNavigationPolicyDecidedCallback(callback);
538 void WebEngine::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
540 GetImplementation(*this).RegisterNewWindowCreatedCallback(callback);
543 void WebEngine::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
545 GetImplementation(*this).RegisterCertificateConfirmedCallback(callback);
548 void WebEngine::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
550 GetImplementation(*this).RegisterSslCertificateChangedCallback(callback);
553 void WebEngine::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback)
555 GetImplementation(*this).RegisterHttpAuthHandlerCallback(callback);
558 void WebEngine::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback)
560 GetImplementation(*this).RegisterContextMenuShownCallback(callback);
563 void WebEngine::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback)
565 GetImplementation(*this).RegisterContextMenuHiddenCallback(callback);
568 void WebEngine::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
570 GetImplementation(*this).GetPlainTextAsynchronously(callback);