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-context.h>
24 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
27 #include <dali/internal/web-engine/common/web-engine-impl.h>
30 #include <dali/public-api/images/pixel-data.h>
34 WebEngine::WebEngine()
38 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
39 : BaseHandle(internal)
43 WebEngine::~WebEngine()
47 WebEngine WebEngine::New()
49 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
51 return WebEngine(engine.Get());
54 WebEngine::WebEngine(const WebEngine& webEngine)
55 : BaseHandle(webEngine)
59 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
61 if(*this != webEngine)
63 BaseHandle::operator=(webEngine);
68 WebEngine WebEngine::DownCast(BaseHandle handle)
70 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
73 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
75 GetImplementation(*this).Create(width, height, locale, timezoneId);
78 void WebEngine::Create(int width, int height, int argc, char** argv)
80 GetImplementation(*this).Create(width, height, argc, argv);
83 void WebEngine::Destroy()
85 GetImplementation(*this).Destroy();
88 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
90 return GetImplementation(*this).GetNativeImageSource();
93 Dali::WebEngineSettings& WebEngine::GetSettings() const
95 return GetImplementation(*this).GetSettings();
98 Dali::WebEngineContext& WebEngine::GetContext() const
100 return GetImplementation(*this).GetContext();
103 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
105 return GetImplementation(*this).GetCookieManager();
108 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
110 return GetImplementation(*this).GetBackForwardList();
113 void WebEngine::LoadUrl(const std::string& url)
115 return GetImplementation(*this).LoadUrl(url);
118 std::string WebEngine::GetTitle() const
120 return GetImplementation(*this).GetTitle();
123 Dali::PixelData WebEngine::GetFavicon() const
125 return GetImplementation(*this).GetFavicon();
128 const std::string& WebEngine::GetUrl()
130 return GetImplementation(*this).GetUrl();
133 void WebEngine::LoadHtmlString(const std::string& htmlString)
135 GetImplementation(*this).LoadHtmlString(htmlString);
138 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
140 return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
143 bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
145 return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
148 void WebEngine::Reload()
150 GetImplementation(*this).Reload();
153 bool WebEngine::ReloadWithoutCache()
155 return GetImplementation(*this).ReloadWithoutCache();
158 void WebEngine::StopLoading()
160 GetImplementation(*this).StopLoading();
163 void WebEngine::Suspend()
165 GetImplementation(*this).Suspend();
168 void WebEngine::Resume()
170 GetImplementation(*this).Resume();
173 void WebEngine::SuspendNetworkLoading()
175 GetImplementation(*this).SuspendNetworkLoading();
178 void WebEngine::ResumeNetworkLoading()
180 GetImplementation(*this).ResumeNetworkLoading();
183 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
185 return GetImplementation(*this).AddCustomHeader(name, value);
188 bool WebEngine::RemoveCustomHeader(const std::string& name)
190 return GetImplementation(*this).RemoveCustomHeader(name);
193 uint32_t WebEngine::StartInspectorServer(uint32_t port)
195 return GetImplementation(*this).StartInspectorServer(port);
198 bool WebEngine::StopInspectorServer()
200 return GetImplementation(*this).StopInspectorServer();
203 void WebEngine::ScrollBy(int deltaX, int deltaY)
205 GetImplementation(*this).ScrollBy(deltaX, deltaY);
208 bool WebEngine::ScrollEdgeBy(int deltaX, int deltaY)
210 return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
213 void WebEngine::SetScrollPosition(int x, int y)
215 GetImplementation(*this).SetScrollPosition(x, y);
218 Dali::Vector2 WebEngine::GetScrollPosition() const
220 return GetImplementation(*this).GetScrollPosition();
223 Dali::Vector2 WebEngine::GetScrollSize() const
225 return GetImplementation(*this).GetScrollSize();
228 Dali::Vector2 WebEngine::GetContentSize() const
230 return GetImplementation(*this).GetContentSize();
233 bool WebEngine::CanGoForward()
235 return GetImplementation(*this).CanGoForward();
238 void WebEngine::GoForward()
240 GetImplementation(*this).GoForward();
243 bool WebEngine::CanGoBack()
245 return GetImplementation(*this).CanGoBack();
248 void WebEngine::GoBack()
250 GetImplementation(*this).GoBack();
253 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
255 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
258 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
260 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
263 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
265 GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
268 void WebEngine::JavaScriptAlertReply()
270 GetImplementation(*this).JavaScriptAlertReply();
273 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
275 GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
278 void WebEngine::JavaScriptConfirmReply(bool confirmed)
280 GetImplementation(*this).JavaScriptConfirmReply(confirmed);
283 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
285 GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
288 void WebEngine::JavaScriptPromptReply(const std::string& result)
290 GetImplementation(*this).JavaScriptPromptReply(result);
293 void WebEngine::ClearHistory()
295 GetImplementation(*this).ClearHistory();
298 void WebEngine::ClearAllTilesResources()
300 GetImplementation(*this).ClearAllTilesResources();
303 const std::string& WebEngine::GetUserAgent() const
305 return GetImplementation(*this).GetUserAgent();
308 void WebEngine::SetUserAgent(const std::string& userAgent)
310 GetImplementation(*this).SetUserAgent(userAgent);
313 void WebEngine::SetSize(int width, int height)
315 GetImplementation(*this).SetSize(width, height);
318 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
320 GetImplementation(*this).SetDocumentBackgroundColor(color);
323 void WebEngine::ClearTilesWhenHidden(bool cleared)
325 GetImplementation(*this).ClearTilesWhenHidden(cleared);
328 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
330 GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
333 void WebEngine::EnableCursorByClient(bool enabled)
335 GetImplementation(*this).EnableCursorByClient(enabled);
338 std::string WebEngine::GetSelectedText() const
340 return GetImplementation(*this).GetSelectedText();
343 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
345 return GetImplementation(*this).SendTouchEvent(touch);
348 bool WebEngine::SendKeyEvent(const KeyEvent& event)
350 return GetImplementation(*this).SendKeyEvent(event);
353 bool WebEngine::SendHoverEvent( const HoverEvent& event )
355 return GetImplementation( *this ).SendHoverEvent( event );
358 bool WebEngine::SendWheelEvent( const WheelEvent& event )
360 return GetImplementation( *this ).SendWheelEvent( event );
363 void WebEngine::SetFocus(bool focused)
365 GetImplementation(*this).SetFocus(focused);
368 void WebEngine::SetPageZoomFactor(float zoomFactor)
370 GetImplementation(*this).SetPageZoomFactor(zoomFactor);
373 float WebEngine::GetPageZoomFactor() const
375 return GetImplementation(*this).GetPageZoomFactor();
378 void WebEngine::SetTextZoomFactor(float zoomFactor)
380 GetImplementation(*this).SetTextZoomFactor(zoomFactor);
383 float WebEngine::GetTextZoomFactor() const
385 return GetImplementation(*this).GetTextZoomFactor();
388 float WebEngine::GetLoadProgressPercentage() const
390 return GetImplementation(*this).GetLoadProgressPercentage();
393 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
395 GetImplementation(*this).SetScaleFactor(scaleFactor, point);
398 float WebEngine::GetScaleFactor() const
400 return GetImplementation(*this).GetScaleFactor();
403 void WebEngine::ActivateAccessibility(bool activated)
405 GetImplementation(*this).ActivateAccessibility(activated);
408 bool WebEngine::SetVisibility(bool visible)
410 return GetImplementation(*this).SetVisibility(visible);
413 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
415 return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
418 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
420 GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
423 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
425 return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
428 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
430 return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
433 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
435 return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
438 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
440 GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
443 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
445 GetImplementation(*this).UpdateDisplayArea(displayArea);
448 void WebEngine::EnableMouseEvents(bool enabled)
450 GetImplementation(*this).EnableMouseEvents(enabled);
453 void WebEngine::EnableKeyEvents(bool enabled)
455 GetImplementation(*this).EnableKeyEvents(enabled);
458 void WebEngine::EnableVideoHole(bool enabled)
460 GetImplementation(*this).EnableVideoHole(enabled);
463 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
465 return GetImplementation(*this).PageLoadStartedSignal();
468 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
470 return GetImplementation(*this).PageLoadInProgressSignal();
473 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
475 return GetImplementation(*this).PageLoadFinishedSignal();
478 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
480 return GetImplementation(*this).PageLoadErrorSignal();
483 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
485 return GetImplementation(*this).ScrollEdgeReachedSignal();
488 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
490 return GetImplementation(*this).UrlChangedSignal();
493 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
495 return GetImplementation(*this).FormRepostDecisionSignal();
498 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
500 return GetImplementation(*this).FrameRenderedSignal();
503 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
505 return GetImplementation(*this).RequestInterceptorSignal();