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