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-certificate.h>
24 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-context-menu-item.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-context-menu.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
32 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
33 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
34 #include <dali/internal/web-engine/common/web-engine-impl.h>
37 #include <dali/public-api/images/pixel-data.h>
41 WebEngine::WebEngine()
45 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
46 : BaseHandle(internal)
50 WebEngine::~WebEngine()
54 WebEngine WebEngine::New()
56 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
58 return WebEngine(engine.Get());
61 WebEngine::WebEngine(const WebEngine& webEngine)
62 : BaseHandle(webEngine)
66 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
68 if(*this != webEngine)
70 BaseHandle::operator=(webEngine);
75 WebEngine WebEngine::DownCast(BaseHandle handle)
77 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
80 void WebEngine::Create(uint32_t width, uint32_t height, const std::string& locale, const std::string& timezoneId)
82 GetImplementation(*this).Create(width, height, locale, timezoneId);
85 void WebEngine::Create(uint32_t width, uint32_t height, uint32_t argc, char** argv)
87 GetImplementation(*this).Create(width, height, argc, argv);
90 void WebEngine::Destroy()
92 GetImplementation(*this).Destroy();
95 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
97 return GetImplementation(*this).GetNativeImageSource();
100 Dali::WebEngineSettings& WebEngine::GetSettings() const
102 return GetImplementation(*this).GetSettings();
105 Dali::WebEngineContext& WebEngine::GetContext() const
107 return GetImplementation(*this).GetContext();
110 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
112 return GetImplementation(*this).GetCookieManager();
115 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
117 return GetImplementation(*this).GetBackForwardList();
120 void WebEngine::LoadUrl(const std::string& url)
122 return GetImplementation(*this).LoadUrl(url);
125 std::string WebEngine::GetTitle() const
127 return GetImplementation(*this).GetTitle();
130 Dali::PixelData WebEngine::GetFavicon() const
132 return GetImplementation(*this).GetFavicon();
135 std::string WebEngine::GetUrl() const
137 return GetImplementation(*this).GetUrl();
140 void WebEngine::LoadHtmlString(const std::string& htmlString)
142 GetImplementation(*this).LoadHtmlString(htmlString);
145 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
147 return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
150 bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
152 return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
155 void WebEngine::Reload()
157 GetImplementation(*this).Reload();
160 bool WebEngine::ReloadWithoutCache()
162 return GetImplementation(*this).ReloadWithoutCache();
165 void WebEngine::StopLoading()
167 GetImplementation(*this).StopLoading();
170 void WebEngine::Suspend()
172 GetImplementation(*this).Suspend();
175 void WebEngine::Resume()
177 GetImplementation(*this).Resume();
180 void WebEngine::SuspendNetworkLoading()
182 GetImplementation(*this).SuspendNetworkLoading();
185 void WebEngine::ResumeNetworkLoading()
187 GetImplementation(*this).ResumeNetworkLoading();
190 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
192 return GetImplementation(*this).AddCustomHeader(name, value);
195 bool WebEngine::RemoveCustomHeader(const std::string& name)
197 return GetImplementation(*this).RemoveCustomHeader(name);
200 uint32_t WebEngine::StartInspectorServer(uint32_t port)
202 return GetImplementation(*this).StartInspectorServer(port);
205 bool WebEngine::StopInspectorServer()
207 return GetImplementation(*this).StopInspectorServer();
210 void WebEngine::ScrollBy(int32_t deltaX, int32_t deltaY)
212 GetImplementation(*this).ScrollBy(deltaX, deltaY);
215 bool WebEngine::ScrollEdgeBy(int32_t deltaX, int32_t deltaY)
217 return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
220 void WebEngine::SetScrollPosition(int32_t x, int32_t y)
222 GetImplementation(*this).SetScrollPosition(x, y);
225 Dali::Vector2 WebEngine::GetScrollPosition() const
227 return GetImplementation(*this).GetScrollPosition();
230 Dali::Vector2 WebEngine::GetScrollSize() const
232 return GetImplementation(*this).GetScrollSize();
235 Dali::Vector2 WebEngine::GetContentSize() const
237 return GetImplementation(*this).GetContentSize();
240 bool WebEngine::CanGoForward()
242 return GetImplementation(*this).CanGoForward();
245 void WebEngine::GoForward()
247 GetImplementation(*this).GoForward();
250 bool WebEngine::CanGoBack()
252 return GetImplementation(*this).CanGoBack();
255 void WebEngine::GoBack()
257 GetImplementation(*this).GoBack();
260 void WebEngine::EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler)
262 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
265 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler)
267 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
270 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
272 GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
275 void WebEngine::JavaScriptAlertReply()
277 GetImplementation(*this).JavaScriptAlertReply();
280 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
282 GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
285 void WebEngine::JavaScriptConfirmReply(bool confirmed)
287 GetImplementation(*this).JavaScriptConfirmReply(confirmed);
290 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
292 GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
295 void WebEngine::JavaScriptPromptReply(const std::string& result)
297 GetImplementation(*this).JavaScriptPromptReply(result);
300 std::unique_ptr<Dali::WebEngineHitTest> WebEngine::CreateHitTest(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode)
302 return GetImplementation(*this).CreateHitTest(x, y, mode);
305 bool WebEngine::CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode, Dali::WebEnginePlugin::WebEngineHitTestCreatedCallback callback)
307 return GetImplementation(*this).CreateHitTestAsynchronously(x, y, mode, callback);
310 void WebEngine::ClearHistory()
312 GetImplementation(*this).ClearHistory();
315 void WebEngine::ClearAllTilesResources()
317 GetImplementation(*this).ClearAllTilesResources();
320 std::string WebEngine::GetUserAgent() const
322 return GetImplementation(*this).GetUserAgent();
325 void WebEngine::SetUserAgent(const std::string& userAgent)
327 GetImplementation(*this).SetUserAgent(userAgent);
330 void WebEngine::SetSize(uint32_t width, uint32_t height)
332 GetImplementation(*this).SetSize(width, height);
335 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
337 GetImplementation(*this).SetDocumentBackgroundColor(color);
340 void WebEngine::ClearTilesWhenHidden(bool cleared)
342 GetImplementation(*this).ClearTilesWhenHidden(cleared);
345 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
347 GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
350 void WebEngine::EnableCursorByClient(bool enabled)
352 GetImplementation(*this).EnableCursorByClient(enabled);
355 std::string WebEngine::GetSelectedText() const
357 return GetImplementation(*this).GetSelectedText();
360 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
362 return GetImplementation(*this).SendTouchEvent(touch);
365 bool WebEngine::SendKeyEvent(const KeyEvent& event)
367 return GetImplementation(*this).SendKeyEvent(event);
370 bool WebEngine::SendHoverEvent(const HoverEvent& event)
372 return GetImplementation(*this).SendHoverEvent(event);
375 bool WebEngine::SendWheelEvent(const WheelEvent& event)
377 return GetImplementation(*this).SendWheelEvent(event);
380 void WebEngine::SetFocus(bool focused)
382 GetImplementation(*this).SetFocus(focused);
385 void WebEngine::SetPageZoomFactor(float zoomFactor)
387 GetImplementation(*this).SetPageZoomFactor(zoomFactor);
390 float WebEngine::GetPageZoomFactor() const
392 return GetImplementation(*this).GetPageZoomFactor();
395 void WebEngine::SetTextZoomFactor(float zoomFactor)
397 GetImplementation(*this).SetTextZoomFactor(zoomFactor);
400 float WebEngine::GetTextZoomFactor() const
402 return GetImplementation(*this).GetTextZoomFactor();
405 float WebEngine::GetLoadProgressPercentage() const
407 return GetImplementation(*this).GetLoadProgressPercentage();
410 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
412 GetImplementation(*this).SetScaleFactor(scaleFactor, point);
415 float WebEngine::GetScaleFactor() const
417 return GetImplementation(*this).GetScaleFactor();
420 void WebEngine::ActivateAccessibility(bool activated)
422 GetImplementation(*this).ActivateAccessibility(activated);
425 bool WebEngine::SetVisibility(bool visible)
427 return GetImplementation(*this).SetVisibility(visible);
430 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
432 return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
435 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
437 GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
440 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int32_t> viewArea, float scaleFactor)
442 return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
445 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int32_t> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
447 return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
450 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
452 return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
455 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
457 GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
460 void WebEngine::UpdateDisplayArea(Dali::Rect<int32_t> displayArea)
462 GetImplementation(*this).UpdateDisplayArea(displayArea);
465 void WebEngine::EnableMouseEvents(bool enabled)
467 GetImplementation(*this).EnableMouseEvents(enabled);
470 void WebEngine::EnableKeyEvents(bool enabled)
472 GetImplementation(*this).EnableKeyEvents(enabled);
475 void WebEngine::EnableVideoHole(bool enabled)
477 GetImplementation(*this).EnableVideoHole(enabled);
480 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
482 return GetImplementation(*this).FrameRenderedSignal();
485 void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
487 GetImplementation(*this).RegisterPageLoadStartedCallback(callback);
490 void WebEngine::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
492 GetImplementation(*this).RegisterPageLoadInProgressCallback(callback);
495 void WebEngine::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
497 GetImplementation(*this).RegisterPageLoadFinishedCallback(callback);
500 void WebEngine::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback)
502 GetImplementation(*this).RegisterPageLoadErrorCallback(callback);
505 void WebEngine::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback)
507 GetImplementation(*this).RegisterScrollEdgeReachedCallback(callback);
510 void WebEngine::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback)
512 GetImplementation(*this).RegisterUrlChangedCallback(callback);
515 void WebEngine::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback)
517 GetImplementation(*this).RegisterFormRepostDecidedCallback(callback);
520 void WebEngine::RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback)
522 GetImplementation(*this).RegisterRequestInterceptorCallback(callback);
525 void WebEngine::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
527 GetImplementation(*this).RegisterConsoleMessageReceivedCallback(callback);
530 void WebEngine::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback)
532 GetImplementation(*this).RegisterResponsePolicyDecidedCallback(callback);
535 void WebEngine::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
537 GetImplementation(*this).RegisterCertificateConfirmedCallback(callback);
540 void WebEngine::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
542 GetImplementation(*this).RegisterSslCertificateChangedCallback(callback);
545 void WebEngine::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback)
547 GetImplementation(*this).RegisterHttpAuthHandlerCallback(callback);
550 void WebEngine::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback)
552 GetImplementation(*this).RegisterContextMenuShownCallback(callback);
555 void WebEngine::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback)
557 GetImplementation(*this).RegisterContextMenuHiddenCallback(callback);
560 void WebEngine::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
562 GetImplementation(*this).GetPlainTextAsynchronously(callback);