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.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
32 #include <dali/internal/web-engine/common/web-engine-impl.h>
35 #include <dali/public-api/images/pixel-data.h>
39 WebEngine::WebEngine()
43 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
44 : BaseHandle(internal)
48 WebEngine::~WebEngine()
52 WebEngine WebEngine::New()
54 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
56 return WebEngine(engine.Get());
59 WebEngine::WebEngine(const WebEngine& webEngine)
60 : BaseHandle(webEngine)
64 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
66 if(*this != webEngine)
68 BaseHandle::operator=(webEngine);
73 WebEngine WebEngine::DownCast(BaseHandle handle)
75 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
78 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
80 GetImplementation(*this).Create(width, height, locale, timezoneId);
83 void WebEngine::Create(int width, int height, int argc, char** argv)
85 GetImplementation(*this).Create(width, height, argc, argv);
88 void WebEngine::Destroy()
90 GetImplementation(*this).Destroy();
93 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
95 return GetImplementation(*this).GetNativeImageSource();
98 Dali::WebEngineSettings& WebEngine::GetSettings() const
100 return GetImplementation(*this).GetSettings();
103 Dali::WebEngineContext& WebEngine::GetContext() const
105 return GetImplementation(*this).GetContext();
108 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
110 return GetImplementation(*this).GetCookieManager();
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 const std::string& WebEngine::GetUrl()
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 std::string& 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(int deltaX, int deltaY)
210 GetImplementation(*this).ScrollBy(deltaX, deltaY);
213 bool WebEngine::ScrollEdgeBy(int deltaX, int deltaY)
215 return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
218 void WebEngine::SetScrollPosition(int x, int 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, std::function<void(const std::string&)> resultHandler)
260 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
263 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> 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 void WebEngine::ClearHistory()
300 GetImplementation(*this).ClearHistory();
303 void WebEngine::ClearAllTilesResources()
305 GetImplementation(*this).ClearAllTilesResources();
308 const std::string& WebEngine::GetUserAgent() const
310 return GetImplementation(*this).GetUserAgent();
313 void WebEngine::SetUserAgent(const std::string& userAgent)
315 GetImplementation(*this).SetUserAgent(userAgent);
318 void WebEngine::SetSize(int width, int height)
320 GetImplementation(*this).SetSize(width, height);
323 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
325 GetImplementation(*this).SetDocumentBackgroundColor(color);
328 void WebEngine::ClearTilesWhenHidden(bool cleared)
330 GetImplementation(*this).ClearTilesWhenHidden(cleared);
333 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
335 GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
338 void WebEngine::EnableCursorByClient(bool enabled)
340 GetImplementation(*this).EnableCursorByClient(enabled);
343 std::string WebEngine::GetSelectedText() const
345 return GetImplementation(*this).GetSelectedText();
348 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
350 return GetImplementation(*this).SendTouchEvent(touch);
353 bool WebEngine::SendKeyEvent(const KeyEvent& event)
355 return GetImplementation(*this).SendKeyEvent(event);
358 bool WebEngine::SendHoverEvent( const HoverEvent& event )
360 return GetImplementation( *this ).SendHoverEvent( event );
363 bool WebEngine::SendWheelEvent( const WheelEvent& event )
365 return GetImplementation( *this ).SendWheelEvent( event );
368 void WebEngine::SetFocus(bool focused)
370 GetImplementation(*this).SetFocus(focused);
373 void WebEngine::SetPageZoomFactor(float zoomFactor)
375 GetImplementation(*this).SetPageZoomFactor(zoomFactor);
378 float WebEngine::GetPageZoomFactor() const
380 return GetImplementation(*this).GetPageZoomFactor();
383 void WebEngine::SetTextZoomFactor(float zoomFactor)
385 GetImplementation(*this).SetTextZoomFactor(zoomFactor);
388 float WebEngine::GetTextZoomFactor() const
390 return GetImplementation(*this).GetTextZoomFactor();
393 float WebEngine::GetLoadProgressPercentage() const
395 return GetImplementation(*this).GetLoadProgressPercentage();
398 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
400 GetImplementation(*this).SetScaleFactor(scaleFactor, point);
403 float WebEngine::GetScaleFactor() const
405 return GetImplementation(*this).GetScaleFactor();
408 void WebEngine::ActivateAccessibility(bool activated)
410 GetImplementation(*this).ActivateAccessibility(activated);
413 bool WebEngine::SetVisibility(bool visible)
415 return GetImplementation(*this).SetVisibility(visible);
418 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
420 return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
423 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
425 GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
428 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
430 return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
433 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
435 return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
438 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
440 return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
443 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
445 GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
448 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
450 GetImplementation(*this).UpdateDisplayArea(displayArea);
453 void WebEngine::EnableMouseEvents(bool enabled)
455 GetImplementation(*this).EnableMouseEvents(enabled);
458 void WebEngine::EnableKeyEvents(bool enabled)
460 GetImplementation(*this).EnableKeyEvents(enabled);
463 void WebEngine::EnableVideoHole(bool enabled)
465 GetImplementation(*this).EnableVideoHole(enabled);
468 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
470 return GetImplementation(*this).PageLoadStartedSignal();
473 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
475 return GetImplementation(*this).PageLoadInProgressSignal();
478 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
480 return GetImplementation(*this).PageLoadFinishedSignal();
483 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
485 return GetImplementation(*this).PageLoadErrorSignal();
488 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
490 return GetImplementation(*this).ScrollEdgeReachedSignal();
493 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
495 return GetImplementation(*this).UrlChangedSignal();
498 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
500 return GetImplementation(*this).FormRepostDecisionSignal();
503 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
505 return GetImplementation(*this).FrameRenderedSignal();
508 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
510 return GetImplementation(*this).RequestInterceptorSignal();
513 Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMessageSignal()
515 return GetImplementation(*this).ConsoleMessageSignal();
518 Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& WebEngine::PolicyDecisionSignal()
520 return GetImplementation(*this).PolicyDecisionSignal();
523 Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::CertificateConfirmSignal()
525 return GetImplementation(*this).CertificateConfirmSignal();
528 Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::SslCertificateChangedSignal()
530 return GetImplementation(*this).SslCertificateChangedSignal();
533 Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& WebEngine::HttpAuthHandlerSignal()
535 return GetImplementation(*this).HttpAuthHandlerSignal();