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-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 WebEngine::WebEngine(const WebEngine& webEngine)
61 : BaseHandle(webEngine)
65 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
67 if(*this != webEngine)
69 BaseHandle::operator=(webEngine);
74 WebEngine WebEngine::DownCast(BaseHandle handle)
76 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
79 void WebEngine::Create(uint32_t width, uint32_t height, const std::string& locale, const std::string& timezoneId)
81 GetImplementation(*this).Create(width, height, locale, timezoneId);
84 void WebEngine::Create(uint32_t width, uint32_t height, uint32_t argc, char** argv)
86 GetImplementation(*this).Create(width, height, argc, argv);
89 void WebEngine::Destroy()
91 GetImplementation(*this).Destroy();
94 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
96 return GetImplementation(*this).GetNativeImageSource();
99 Dali::WebEngineSettings& WebEngine::GetSettings() const
101 return GetImplementation(*this).GetSettings();
104 Dali::WebEngineContext& WebEngine::GetContext() const
106 return GetImplementation(*this).GetContext();
109 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
111 return GetImplementation(*this).GetCookieManager();
114 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
116 return GetImplementation(*this).GetBackForwardList();
119 void WebEngine::LoadUrl(const std::string& url)
121 return GetImplementation(*this).LoadUrl(url);
124 std::string WebEngine::GetTitle() const
126 return GetImplementation(*this).GetTitle();
129 Dali::PixelData WebEngine::GetFavicon() const
131 return GetImplementation(*this).GetFavicon();
134 std::string WebEngine::GetUrl() const
136 return GetImplementation(*this).GetUrl();
139 void WebEngine::LoadHtmlString(const std::string& htmlString)
141 GetImplementation(*this).LoadHtmlString(htmlString);
144 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
146 return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
149 bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
151 return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
154 void WebEngine::Reload()
156 GetImplementation(*this).Reload();
159 bool WebEngine::ReloadWithoutCache()
161 return GetImplementation(*this).ReloadWithoutCache();
164 void WebEngine::StopLoading()
166 GetImplementation(*this).StopLoading();
169 void WebEngine::Suspend()
171 GetImplementation(*this).Suspend();
174 void WebEngine::Resume()
176 GetImplementation(*this).Resume();
179 void WebEngine::SuspendNetworkLoading()
181 GetImplementation(*this).SuspendNetworkLoading();
184 void WebEngine::ResumeNetworkLoading()
186 GetImplementation(*this).ResumeNetworkLoading();
189 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
191 return GetImplementation(*this).AddCustomHeader(name, value);
194 bool WebEngine::RemoveCustomHeader(const std::string& name)
196 return GetImplementation(*this).RemoveCustomHeader(name);
199 uint32_t WebEngine::StartInspectorServer(uint32_t port)
201 return GetImplementation(*this).StartInspectorServer(port);
204 bool WebEngine::StopInspectorServer()
206 return GetImplementation(*this).StopInspectorServer();
209 void WebEngine::ScrollBy(int32_t deltaX, int32_t deltaY)
211 GetImplementation(*this).ScrollBy(deltaX, deltaY);
214 bool WebEngine::ScrollEdgeBy(int32_t deltaX, int32_t deltaY)
216 return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
219 void WebEngine::SetScrollPosition(int32_t x, int32_t y)
221 GetImplementation(*this).SetScrollPosition(x, y);
224 Dali::Vector2 WebEngine::GetScrollPosition() const
226 return GetImplementation(*this).GetScrollPosition();
229 Dali::Vector2 WebEngine::GetScrollSize() const
231 return GetImplementation(*this).GetScrollSize();
234 Dali::Vector2 WebEngine::GetContentSize() const
236 return GetImplementation(*this).GetContentSize();
239 bool WebEngine::CanGoForward()
241 return GetImplementation(*this).CanGoForward();
244 void WebEngine::GoForward()
246 GetImplementation(*this).GoForward();
249 bool WebEngine::CanGoBack()
251 return GetImplementation(*this).CanGoBack();
254 void WebEngine::GoBack()
256 GetImplementation(*this).GoBack();
259 void WebEngine::EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler)
261 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
264 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler)
266 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
269 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
271 GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
274 void WebEngine::JavaScriptAlertReply()
276 GetImplementation(*this).JavaScriptAlertReply();
279 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
281 GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
284 void WebEngine::JavaScriptConfirmReply(bool confirmed)
286 GetImplementation(*this).JavaScriptConfirmReply(confirmed);
289 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
291 GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
294 void WebEngine::JavaScriptPromptReply(const std::string& result)
296 GetImplementation(*this).JavaScriptPromptReply(result);
299 std::unique_ptr<Dali::WebEngineHitTest> WebEngine::CreateHitTest(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode)
301 return GetImplementation(*this).CreateHitTest(x, y, mode);
304 bool WebEngine::CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode, Dali::WebEnginePlugin::WebEngineHitTestCreatedCallback callback)
306 return GetImplementation(*this).CreateHitTestAsynchronously(x, y, mode, callback);
309 void WebEngine::ClearHistory()
311 GetImplementation(*this).ClearHistory();
314 void WebEngine::ClearAllTilesResources()
316 GetImplementation(*this).ClearAllTilesResources();
319 std::string WebEngine::GetUserAgent() const
321 return GetImplementation(*this).GetUserAgent();
324 void WebEngine::SetUserAgent(const std::string& userAgent)
326 GetImplementation(*this).SetUserAgent(userAgent);
329 void WebEngine::SetSize(uint32_t width, uint32_t height)
331 GetImplementation(*this).SetSize(width, height);
334 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
336 GetImplementation(*this).SetDocumentBackgroundColor(color);
339 void WebEngine::ClearTilesWhenHidden(bool cleared)
341 GetImplementation(*this).ClearTilesWhenHidden(cleared);
344 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
346 GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
349 void WebEngine::EnableCursorByClient(bool enabled)
351 GetImplementation(*this).EnableCursorByClient(enabled);
354 std::string WebEngine::GetSelectedText() const
356 return GetImplementation(*this).GetSelectedText();
359 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
361 return GetImplementation(*this).SendTouchEvent(touch);
364 bool WebEngine::SendKeyEvent(const KeyEvent& event)
366 return GetImplementation(*this).SendKeyEvent(event);
369 bool WebEngine::SendHoverEvent(const HoverEvent& event)
371 return GetImplementation(*this).SendHoverEvent(event);
374 bool WebEngine::SendWheelEvent(const WheelEvent& event)
376 return GetImplementation(*this).SendWheelEvent(event);
379 void WebEngine::SetFocus(bool focused)
381 GetImplementation(*this).SetFocus(focused);
384 void WebEngine::SetPageZoomFactor(float zoomFactor)
386 GetImplementation(*this).SetPageZoomFactor(zoomFactor);
389 float WebEngine::GetPageZoomFactor() const
391 return GetImplementation(*this).GetPageZoomFactor();
394 void WebEngine::SetTextZoomFactor(float zoomFactor)
396 GetImplementation(*this).SetTextZoomFactor(zoomFactor);
399 float WebEngine::GetTextZoomFactor() const
401 return GetImplementation(*this).GetTextZoomFactor();
404 float WebEngine::GetLoadProgressPercentage() const
406 return GetImplementation(*this).GetLoadProgressPercentage();
409 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
411 GetImplementation(*this).SetScaleFactor(scaleFactor, point);
414 float WebEngine::GetScaleFactor() const
416 return GetImplementation(*this).GetScaleFactor();
419 void WebEngine::ActivateAccessibility(bool activated)
421 GetImplementation(*this).ActivateAccessibility(activated);
424 bool WebEngine::SetVisibility(bool visible)
426 return GetImplementation(*this).SetVisibility(visible);
429 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
431 return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
434 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
436 GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
439 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int32_t> viewArea, float scaleFactor)
441 return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
444 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int32_t> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
446 return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
449 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
451 return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
454 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
456 GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
459 void WebEngine::UpdateDisplayArea(Dali::Rect<int32_t> displayArea)
461 GetImplementation(*this).UpdateDisplayArea(displayArea);
464 void WebEngine::EnableMouseEvents(bool enabled)
466 GetImplementation(*this).EnableMouseEvents(enabled);
469 void WebEngine::EnableKeyEvents(bool enabled)
471 GetImplementation(*this).EnableKeyEvents(enabled);
474 void WebEngine::EnableVideoHole(bool enabled)
476 GetImplementation(*this).EnableVideoHole(enabled);
479 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
481 return GetImplementation(*this).FrameRenderedSignal();
484 void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
486 GetImplementation(*this).RegisterPageLoadStartedCallback(callback);
489 void WebEngine::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
491 GetImplementation(*this).RegisterPageLoadInProgressCallback(callback);
494 void WebEngine::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
496 GetImplementation(*this).RegisterPageLoadFinishedCallback(callback);
499 void WebEngine::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback)
501 GetImplementation(*this).RegisterPageLoadErrorCallback(callback);
504 void WebEngine::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback)
506 GetImplementation(*this).RegisterScrollEdgeReachedCallback(callback);
509 void WebEngine::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback)
511 GetImplementation(*this).RegisterUrlChangedCallback(callback);
514 void WebEngine::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback)
516 GetImplementation(*this).RegisterFormRepostDecidedCallback(callback);
519 void WebEngine::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
521 GetImplementation(*this).RegisterConsoleMessageReceivedCallback(callback);
524 void WebEngine::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback)
526 GetImplementation(*this).RegisterResponsePolicyDecidedCallback(callback);
529 void WebEngine::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
531 GetImplementation(*this).RegisterCertificateConfirmedCallback(callback);
534 void WebEngine::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
536 GetImplementation(*this).RegisterSslCertificateChangedCallback(callback);
539 void WebEngine::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback)
541 GetImplementation(*this).RegisterHttpAuthHandlerCallback(callback);
544 void WebEngine::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback)
546 GetImplementation(*this).RegisterContextMenuShownCallback(callback);
549 void WebEngine::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback)
551 GetImplementation(*this).RegisterContextMenuHiddenCallback(callback);
554 void WebEngine::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
556 GetImplementation(*this).GetPlainTextAsynchronously(callback);