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