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-settings.h>
26 #include <dali/internal/web-engine/common/web-engine-impl.h>
29 #include <dali/public-api/images/pixel-data.h>
33 WebEngine::WebEngine()
37 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
38 : BaseHandle(internal)
42 WebEngine::~WebEngine()
46 WebEngine WebEngine::New()
48 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
50 return WebEngine(engine.Get());
53 WebEngine::WebEngine(const WebEngine& webEngine)
54 : BaseHandle(webEngine)
58 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
60 if(*this != webEngine)
62 BaseHandle::operator=(webEngine);
67 WebEngine WebEngine::DownCast(BaseHandle handle)
69 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
72 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
74 GetImplementation(*this).Create(width, height, locale, timezoneId);
77 void WebEngine::Create(int width, int height, int argc, char** argv)
79 GetImplementation(*this).Create(width, height, argc, argv);
82 void WebEngine::Destroy()
84 GetImplementation(*this).Destroy();
87 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
89 return GetImplementation(*this).GetNativeImageSource();
92 Dali::WebEngineSettings& WebEngine::GetSettings() const
94 return GetImplementation(*this).GetSettings();
97 Dali::WebEngineContext& WebEngine::GetContext() const
99 return GetImplementation(*this).GetContext();
102 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
104 return GetImplementation(*this).GetCookieManager();
107 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
109 return GetImplementation(*this).GetBackForwardList();
112 void WebEngine::LoadUrl(const std::string& url)
114 return GetImplementation(*this).LoadUrl(url);
117 std::string WebEngine::GetTitle() const
119 return GetImplementation(*this).GetTitle();
122 Dali::PixelData WebEngine::GetFavicon() const
124 return GetImplementation(*this).GetFavicon();
127 const std::string& WebEngine::GetUrl()
129 return GetImplementation(*this).GetUrl();
132 void WebEngine::LoadHtmlString(const std::string& htmlString)
134 GetImplementation(*this).LoadHtmlString(htmlString);
137 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
139 return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
142 bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
144 return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
147 void WebEngine::Reload()
149 GetImplementation(*this).Reload();
152 bool WebEngine::ReloadWithoutCache()
154 return GetImplementation(*this).ReloadWithoutCache();
157 void WebEngine::StopLoading()
159 GetImplementation(*this).StopLoading();
162 void WebEngine::Suspend()
164 GetImplementation(*this).Suspend();
167 void WebEngine::Resume()
169 GetImplementation(*this).Resume();
172 void WebEngine::SuspendNetworkLoading()
174 GetImplementation(*this).SuspendNetworkLoading();
177 void WebEngine::ResumeNetworkLoading()
179 GetImplementation(*this).ResumeNetworkLoading();
182 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
184 return GetImplementation(*this).AddCustomHeader(name, value);
187 bool WebEngine::RemoveCustomHeader(const std::string& name)
189 return GetImplementation(*this).RemoveCustomHeader(name);
192 uint32_t WebEngine::StartInspectorServer(uint32_t port)
194 return GetImplementation(*this).StartInspectorServer(port);
197 bool WebEngine::StopInspectorServer()
199 return GetImplementation(*this).StopInspectorServer();
202 void WebEngine::ScrollBy(int deltaX, int deltaY)
204 GetImplementation(*this).ScrollBy(deltaX, deltaY);
207 bool WebEngine::ScrollEdgeBy(int deltaX, int deltaY)
209 return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
212 void WebEngine::SetScrollPosition(int x, int y)
214 GetImplementation(*this).SetScrollPosition(x, y);
217 Dali::Vector2 WebEngine::GetScrollPosition() const
219 return GetImplementation(*this).GetScrollPosition();
222 Dali::Vector2 WebEngine::GetScrollSize() const
224 return GetImplementation(*this).GetScrollSize();
227 Dali::Vector2 WebEngine::GetContentSize() const
229 return GetImplementation(*this).GetContentSize();
232 bool WebEngine::CanGoForward()
234 return GetImplementation(*this).CanGoForward();
237 void WebEngine::GoForward()
239 GetImplementation(*this).GoForward();
242 bool WebEngine::CanGoBack()
244 return GetImplementation(*this).CanGoBack();
247 void WebEngine::GoBack()
249 GetImplementation(*this).GoBack();
252 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
254 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
257 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
259 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
262 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
264 GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
267 void WebEngine::JavaScriptAlertReply()
269 GetImplementation(*this).JavaScriptAlertReply();
272 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
274 GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
277 void WebEngine::JavaScriptConfirmReply(bool confirmed)
279 GetImplementation(*this).JavaScriptConfirmReply(confirmed);
282 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
284 GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
287 void WebEngine::JavaScriptPromptReply(const std::string& result)
289 GetImplementation(*this).JavaScriptPromptReply(result);
292 void WebEngine::ClearHistory()
294 GetImplementation(*this).ClearHistory();
297 void WebEngine::ClearAllTilesResources()
299 GetImplementation(*this).ClearAllTilesResources();
302 const std::string& WebEngine::GetUserAgent() const
304 return GetImplementation(*this).GetUserAgent();
307 void WebEngine::SetUserAgent(const std::string& userAgent)
309 GetImplementation(*this).SetUserAgent(userAgent);
312 void WebEngine::SetSize(int width, int height)
314 GetImplementation(*this).SetSize(width, height);
317 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
319 GetImplementation(*this).SetDocumentBackgroundColor(color);
322 void WebEngine::ClearTilesWhenHidden(bool cleared)
324 GetImplementation(*this).ClearTilesWhenHidden(cleared);
327 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
329 GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
332 void WebEngine::EnableCursorByClient(bool enabled)
334 GetImplementation(*this).EnableCursorByClient(enabled);
337 std::string WebEngine::GetSelectedText() const
339 return GetImplementation(*this).GetSelectedText();
342 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
344 return GetImplementation(*this).SendTouchEvent(touch);
347 bool WebEngine::SendKeyEvent(const KeyEvent& event)
349 return GetImplementation(*this).SendKeyEvent(event);
352 bool WebEngine::SendHoverEvent( const HoverEvent& event )
354 return GetImplementation( *this ).SendHoverEvent( event );
357 bool WebEngine::SendWheelEvent( const WheelEvent& event )
359 return GetImplementation( *this ).SendWheelEvent( event );
362 void WebEngine::SetFocus(bool focused)
364 GetImplementation(*this).SetFocus(focused);
367 void WebEngine::SetPageZoomFactor(float zoomFactor)
369 GetImplementation(*this).SetPageZoomFactor(zoomFactor);
372 float WebEngine::GetPageZoomFactor() const
374 return GetImplementation(*this).GetPageZoomFactor();
377 void WebEngine::SetTextZoomFactor(float zoomFactor)
379 GetImplementation(*this).SetTextZoomFactor(zoomFactor);
382 float WebEngine::GetTextZoomFactor() const
384 return GetImplementation(*this).GetTextZoomFactor();
387 float WebEngine::GetLoadProgressPercentage() const
389 return GetImplementation(*this).GetLoadProgressPercentage();
392 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
394 GetImplementation(*this).SetScaleFactor(scaleFactor, point);
397 float WebEngine::GetScaleFactor() const
399 return GetImplementation(*this).GetScaleFactor();
402 void WebEngine::ActivateAccessibility(bool activated)
404 GetImplementation(*this).ActivateAccessibility(activated);
407 bool WebEngine::SetVisibility(bool visible)
409 return GetImplementation(*this).SetVisibility(visible);
412 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
414 return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
417 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
419 GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
422 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
424 return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
427 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
429 return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
432 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
434 return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
437 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
439 GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
442 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
444 GetImplementation(*this).UpdateDisplayArea(displayArea);
447 void WebEngine::EnableMouseEvents(bool enabled)
449 GetImplementation(*this).EnableMouseEvents(enabled);
452 void WebEngine::EnableKeyEvents(bool enabled)
454 GetImplementation(*this).EnableKeyEvents(enabled);
457 void WebEngine::EnableVideoHole(bool enabled)
459 GetImplementation(*this).EnableVideoHole(enabled);
462 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
464 return GetImplementation(*this).PageLoadStartedSignal();
467 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
469 return GetImplementation(*this).PageLoadInProgressSignal();
472 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
474 return GetImplementation(*this).PageLoadFinishedSignal();
477 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
479 return GetImplementation(*this).PageLoadErrorSignal();
482 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
484 return GetImplementation(*this).ScrollEdgeReachedSignal();
487 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
489 return GetImplementation(*this).UrlChangedSignal();
492 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
494 return GetImplementation(*this).FormRepostDecisionSignal();
497 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
499 return GetImplementation(*this).FrameRenderedSignal();