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