65a93dc8b004b38f2713eda717570c05cff65782
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/devel-api/adaptor-framework/web-engine.h>
20
21 // INTERNAL INCLUDES
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>
28
29 // EXTERNAL INCLUDES
30 #include <dali/public-api/images/pixel-data.h>
31
32 namespace Dali
33 {
34 WebEngine::WebEngine()
35 {
36 }
37
38 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
39 : BaseHandle(internal)
40 {
41 }
42
43 WebEngine::~WebEngine()
44 {
45 }
46
47 WebEngine WebEngine::New()
48 {
49   Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
50
51   return WebEngine(engine.Get());
52 }
53
54 WebEngine::WebEngine(const WebEngine& webEngine)
55 : BaseHandle(webEngine)
56 {
57 }
58
59 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
60 {
61   if(*this != webEngine)
62   {
63     BaseHandle::operator=(webEngine);
64   }
65   return *this;
66 }
67
68 WebEngine WebEngine::DownCast(BaseHandle handle)
69 {
70   return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
71 }
72
73 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
74 {
75   GetImplementation(*this).Create(width, height, locale, timezoneId);
76 }
77
78 void WebEngine::Create(int width, int height, int argc, char** argv)
79 {
80   GetImplementation(*this).Create(width, height, argc, argv);
81 }
82
83 void WebEngine::Destroy()
84 {
85   GetImplementation(*this).Destroy();
86 }
87
88 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
89 {
90   return GetImplementation(*this).GetNativeImageSource();
91 }
92
93 Dali::WebEngineSettings& WebEngine::GetSettings() const
94 {
95   return GetImplementation(*this).GetSettings();
96 }
97
98 Dali::WebEngineContext& WebEngine::GetContext() const
99 {
100   return GetImplementation(*this).GetContext();
101 }
102
103 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
104 {
105   return GetImplementation(*this).GetCookieManager();
106 }
107
108 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
109 {
110   return GetImplementation(*this).GetBackForwardList();
111 }
112
113 void WebEngine::LoadUrl(const std::string& url)
114 {
115   return GetImplementation(*this).LoadUrl(url);
116 }
117
118 std::string WebEngine::GetTitle() const
119 {
120   return GetImplementation(*this).GetTitle();
121 }
122
123 Dali::PixelData WebEngine::GetFavicon() const
124 {
125   return GetImplementation(*this).GetFavicon();
126 }
127
128 const std::string& WebEngine::GetUrl()
129 {
130   return GetImplementation(*this).GetUrl();
131 }
132
133 void WebEngine::LoadHtmlString(const std::string& htmlString)
134 {
135   GetImplementation(*this).LoadHtmlString(htmlString);
136 }
137
138 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
139 {
140   return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
141 }
142
143 bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
144 {
145   return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
146 }
147
148 void WebEngine::Reload()
149 {
150   GetImplementation(*this).Reload();
151 }
152
153 bool WebEngine::ReloadWithoutCache()
154 {
155   return GetImplementation(*this).ReloadWithoutCache();
156 }
157
158 void WebEngine::StopLoading()
159 {
160   GetImplementation(*this).StopLoading();
161 }
162
163 void WebEngine::Suspend()
164 {
165   GetImplementation(*this).Suspend();
166 }
167
168 void WebEngine::Resume()
169 {
170   GetImplementation(*this).Resume();
171 }
172
173 void WebEngine::SuspendNetworkLoading()
174 {
175   GetImplementation(*this).SuspendNetworkLoading();
176 }
177
178 void WebEngine::ResumeNetworkLoading()
179 {
180   GetImplementation(*this).ResumeNetworkLoading();
181 }
182
183 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
184 {
185   return GetImplementation(*this).AddCustomHeader(name, value);
186 }
187
188 bool WebEngine::RemoveCustomHeader(const std::string& name)
189 {
190   return GetImplementation(*this).RemoveCustomHeader(name);
191 }
192
193 uint32_t WebEngine::StartInspectorServer(uint32_t port)
194 {
195   return GetImplementation(*this).StartInspectorServer(port);
196 }
197
198 bool WebEngine::StopInspectorServer()
199 {
200   return GetImplementation(*this).StopInspectorServer();
201 }
202
203 void WebEngine::ScrollBy(int deltaX, int deltaY)
204 {
205   GetImplementation(*this).ScrollBy(deltaX, deltaY);
206 }
207
208 bool WebEngine::ScrollEdgeBy(int deltaX, int deltaY)
209 {
210   return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
211 }
212
213 void WebEngine::SetScrollPosition(int x, int y)
214 {
215   GetImplementation(*this).SetScrollPosition(x, y);
216 }
217
218 Dali::Vector2 WebEngine::GetScrollPosition() const
219 {
220   return GetImplementation(*this).GetScrollPosition();
221 }
222
223 Dali::Vector2 WebEngine::GetScrollSize() const
224 {
225   return GetImplementation(*this).GetScrollSize();
226 }
227
228 Dali::Vector2 WebEngine::GetContentSize() const
229 {
230   return GetImplementation(*this).GetContentSize();
231 }
232
233 bool WebEngine::CanGoForward()
234 {
235   return GetImplementation(*this).CanGoForward();
236 }
237
238 void WebEngine::GoForward()
239 {
240   GetImplementation(*this).GoForward();
241 }
242
243 bool WebEngine::CanGoBack()
244 {
245   return GetImplementation(*this).CanGoBack();
246 }
247
248 void WebEngine::GoBack()
249 {
250   GetImplementation(*this).GoBack();
251 }
252
253 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
254 {
255   GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
256 }
257
258 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
259 {
260   GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
261 }
262
263 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
264 {
265   GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
266 }
267
268 void WebEngine::JavaScriptAlertReply()
269 {
270   GetImplementation(*this).JavaScriptAlertReply();
271 }
272
273 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
274 {
275   GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
276 }
277
278 void WebEngine::JavaScriptConfirmReply(bool confirmed)
279 {
280   GetImplementation(*this).JavaScriptConfirmReply(confirmed);
281 }
282
283 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
284 {
285   GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
286 }
287
288 void WebEngine::JavaScriptPromptReply(const std::string& result)
289 {
290   GetImplementation(*this).JavaScriptPromptReply(result);
291 }
292
293 void WebEngine::ClearHistory()
294 {
295   GetImplementation(*this).ClearHistory();
296 }
297
298 void WebEngine::ClearAllTilesResources()
299 {
300   GetImplementation(*this).ClearAllTilesResources();
301 }
302
303 const std::string& WebEngine::GetUserAgent() const
304 {
305   return GetImplementation(*this).GetUserAgent();
306 }
307
308 void WebEngine::SetUserAgent(const std::string& userAgent)
309 {
310   GetImplementation(*this).SetUserAgent(userAgent);
311 }
312
313 void WebEngine::SetSize(int width, int height)
314 {
315   GetImplementation(*this).SetSize(width, height);
316 }
317
318 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
319 {
320   GetImplementation(*this).SetDocumentBackgroundColor(color);
321 }
322
323 void WebEngine::ClearTilesWhenHidden(bool cleared)
324 {
325   GetImplementation(*this).ClearTilesWhenHidden(cleared);
326 }
327
328 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
329 {
330   GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
331 }
332
333 void WebEngine::EnableCursorByClient(bool enabled)
334 {
335   GetImplementation(*this).EnableCursorByClient(enabled);
336 }
337
338 std::string WebEngine::GetSelectedText() const
339 {
340   return GetImplementation(*this).GetSelectedText();
341 }
342
343 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
344 {
345   return GetImplementation(*this).SendTouchEvent(touch);
346 }
347
348 bool WebEngine::SendKeyEvent(const KeyEvent& event)
349 {
350   return GetImplementation(*this).SendKeyEvent(event);
351 }
352
353 bool WebEngine::SendHoverEvent( const HoverEvent& event )
354 {
355   return GetImplementation( *this ).SendHoverEvent( event );
356 }
357
358 bool WebEngine::SendWheelEvent( const WheelEvent& event )
359 {
360   return GetImplementation( *this ).SendWheelEvent( event );
361 }
362
363 void WebEngine::SetFocus(bool focused)
364 {
365   GetImplementation(*this).SetFocus(focused);
366 }
367
368 void WebEngine::SetPageZoomFactor(float zoomFactor)
369 {
370   GetImplementation(*this).SetPageZoomFactor(zoomFactor);
371 }
372
373 float WebEngine::GetPageZoomFactor() const
374 {
375   return GetImplementation(*this).GetPageZoomFactor();
376 }
377
378 void WebEngine::SetTextZoomFactor(float zoomFactor)
379 {
380   GetImplementation(*this).SetTextZoomFactor(zoomFactor);
381 }
382
383 float WebEngine::GetTextZoomFactor() const
384 {
385   return GetImplementation(*this).GetTextZoomFactor();
386 }
387
388 float WebEngine::GetLoadProgressPercentage() const
389 {
390   return GetImplementation(*this).GetLoadProgressPercentage();
391 }
392
393 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
394 {
395   GetImplementation(*this).SetScaleFactor(scaleFactor, point);
396 }
397
398 float WebEngine::GetScaleFactor() const
399 {
400   return GetImplementation(*this).GetScaleFactor();
401 }
402
403 void WebEngine::ActivateAccessibility(bool activated)
404 {
405   GetImplementation(*this).ActivateAccessibility(activated);
406 }
407
408 bool WebEngine::SetVisibility(bool visible)
409 {
410   return GetImplementation(*this).SetVisibility(visible);
411 }
412
413 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
414 {
415   return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
416 }
417
418 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
419 {
420   GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
421 }
422
423 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
424 {
425   return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
426 }
427
428 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
429 {
430   return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
431 }
432
433 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
434 {
435   return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
436 }
437
438 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
439 {
440   GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
441 }
442
443 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
444 {
445   GetImplementation(*this).UpdateDisplayArea(displayArea);
446 }
447
448 void WebEngine::EnableMouseEvents(bool enabled)
449 {
450   GetImplementation(*this).EnableMouseEvents(enabled);
451 }
452
453 void WebEngine::EnableKeyEvents(bool enabled)
454 {
455   GetImplementation(*this).EnableKeyEvents(enabled);
456 }
457
458 void WebEngine::EnableVideoHole(bool enabled)
459 {
460   GetImplementation(*this).EnableVideoHole(enabled);
461 }
462
463 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
464 {
465   return GetImplementation(*this).PageLoadStartedSignal();
466 }
467
468 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
469 {
470   return GetImplementation(*this).PageLoadInProgressSignal();
471 }
472
473 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
474 {
475   return GetImplementation(*this).PageLoadFinishedSignal();
476 }
477
478 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
479 {
480   return GetImplementation(*this).PageLoadErrorSignal();
481 }
482
483 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
484 {
485   return GetImplementation(*this).ScrollEdgeReachedSignal();
486 }
487
488 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
489 {
490   return GetImplementation(*this).UrlChangedSignal();
491 }
492
493 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
494 {
495   return GetImplementation(*this).FormRepostDecisionSignal();
496 }
497
498 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
499 {
500   return GetImplementation(*this).FrameRenderedSignal();
501 }
502
503 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
504 {
505   return GetImplementation(*this).RequestInterceptorSignal();
506 }
507
508 } // namespace Dali