Implement WebEngine::GetPlainTextAsynchronously
[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(uint32_t width, uint32_t height, const std::string& locale, const std::string& timezoneId)
81 {
82   GetImplementation(*this).Create(width, height, locale, timezoneId);
83 }
84
85 void WebEngine::Create(uint32_t width, uint32_t height, uint32_t 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 std::string WebEngine::GetUrl() const
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(int32_t deltaX, int32_t deltaY)
211 {
212   GetImplementation(*this).ScrollBy(deltaX, deltaY);
213 }
214
215 bool WebEngine::ScrollEdgeBy(int32_t deltaX, int32_t deltaY)
216 {
217   return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
218 }
219
220 void WebEngine::SetScrollPosition(int32_t x, int32_t 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, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler)
261 {
262   GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
263 }
264
265 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback 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 std::unique_ptr<Dali::WebEngineHitTest> WebEngine::CreateHitTest(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode)
301 {
302   return GetImplementation(*this).CreateHitTest(x, y, mode);
303 }
304
305 bool WebEngine::CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode, Dali::WebEnginePlugin::WebEngineHitTestCreatedCallback callback)
306 {
307   return GetImplementation(*this).CreateHitTestAsynchronously(x, y, mode, callback);
308 }
309
310 void WebEngine::ClearHistory()
311 {
312   GetImplementation(*this).ClearHistory();
313 }
314
315 void WebEngine::ClearAllTilesResources()
316 {
317   GetImplementation(*this).ClearAllTilesResources();
318 }
319
320 std::string WebEngine::GetUserAgent() const
321 {
322   return GetImplementation(*this).GetUserAgent();
323 }
324
325 void WebEngine::SetUserAgent(const std::string& userAgent)
326 {
327   GetImplementation(*this).SetUserAgent(userAgent);
328 }
329
330 void WebEngine::SetSize(uint32_t width, uint32_t height)
331 {
332   GetImplementation(*this).SetSize(width, height);
333 }
334
335 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
336 {
337   GetImplementation(*this).SetDocumentBackgroundColor(color);
338 }
339
340 void WebEngine::ClearTilesWhenHidden(bool cleared)
341 {
342   GetImplementation(*this).ClearTilesWhenHidden(cleared);
343 }
344
345 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
346 {
347   GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
348 }
349
350 void WebEngine::EnableCursorByClient(bool enabled)
351 {
352   GetImplementation(*this).EnableCursorByClient(enabled);
353 }
354
355 std::string WebEngine::GetSelectedText() const
356 {
357   return GetImplementation(*this).GetSelectedText();
358 }
359
360 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
361 {
362   return GetImplementation(*this).SendTouchEvent(touch);
363 }
364
365 bool WebEngine::SendKeyEvent(const KeyEvent& event)
366 {
367   return GetImplementation(*this).SendKeyEvent(event);
368 }
369
370 bool WebEngine::SendHoverEvent(const HoverEvent& event)
371 {
372   return GetImplementation(*this).SendHoverEvent(event);
373 }
374
375 bool WebEngine::SendWheelEvent(const WheelEvent& event)
376 {
377   return GetImplementation(*this).SendWheelEvent(event);
378 }
379
380 void WebEngine::SetFocus(bool focused)
381 {
382   GetImplementation(*this).SetFocus(focused);
383 }
384
385 void WebEngine::SetPageZoomFactor(float zoomFactor)
386 {
387   GetImplementation(*this).SetPageZoomFactor(zoomFactor);
388 }
389
390 float WebEngine::GetPageZoomFactor() const
391 {
392   return GetImplementation(*this).GetPageZoomFactor();
393 }
394
395 void WebEngine::SetTextZoomFactor(float zoomFactor)
396 {
397   GetImplementation(*this).SetTextZoomFactor(zoomFactor);
398 }
399
400 float WebEngine::GetTextZoomFactor() const
401 {
402   return GetImplementation(*this).GetTextZoomFactor();
403 }
404
405 float WebEngine::GetLoadProgressPercentage() const
406 {
407   return GetImplementation(*this).GetLoadProgressPercentage();
408 }
409
410 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
411 {
412   GetImplementation(*this).SetScaleFactor(scaleFactor, point);
413 }
414
415 float WebEngine::GetScaleFactor() const
416 {
417   return GetImplementation(*this).GetScaleFactor();
418 }
419
420 void WebEngine::ActivateAccessibility(bool activated)
421 {
422   GetImplementation(*this).ActivateAccessibility(activated);
423 }
424
425 bool WebEngine::SetVisibility(bool visible)
426 {
427   return GetImplementation(*this).SetVisibility(visible);
428 }
429
430 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
431 {
432   return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
433 }
434
435 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
436 {
437   GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
438 }
439
440 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int32_t> viewArea, float scaleFactor)
441 {
442   return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
443 }
444
445 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int32_t> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
446 {
447   return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
448 }
449
450 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
451 {
452   return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
453 }
454
455 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
456 {
457   GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
458 }
459
460 void WebEngine::UpdateDisplayArea(Dali::Rect<int32_t> displayArea)
461 {
462   GetImplementation(*this).UpdateDisplayArea(displayArea);
463 }
464
465 void WebEngine::EnableMouseEvents(bool enabled)
466 {
467   GetImplementation(*this).EnableMouseEvents(enabled);
468 }
469
470 void WebEngine::EnableKeyEvents(bool enabled)
471 {
472   GetImplementation(*this).EnableKeyEvents(enabled);
473 }
474
475 void WebEngine::EnableVideoHole(bool enabled)
476 {
477   GetImplementation(*this).EnableVideoHole(enabled);
478 }
479
480 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
481 {
482   return GetImplementation(*this).FrameRenderedSignal();
483 }
484
485 void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
486 {
487   GetImplementation(*this).RegisterPageLoadStartedCallback(callback);
488 }
489
490 void WebEngine::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
491 {
492   GetImplementation(*this).RegisterPageLoadInProgressCallback(callback);
493 }
494
495 void WebEngine::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
496 {
497   GetImplementation(*this).RegisterPageLoadFinishedCallback(callback);
498 }
499
500 void WebEngine::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback)
501 {
502   GetImplementation(*this).RegisterPageLoadErrorCallback(callback);
503 }
504
505 void WebEngine::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback)
506 {
507   GetImplementation(*this).RegisterScrollEdgeReachedCallback(callback);
508 }
509
510 void WebEngine::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback)
511 {
512   GetImplementation(*this).RegisterUrlChangedCallback(callback);
513 }
514
515 void WebEngine::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback)
516 {
517   GetImplementation(*this).RegisterFormRepostDecidedCallback(callback);
518 }
519
520 void WebEngine::RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback)
521 {
522   GetImplementation(*this).RegisterRequestInterceptorCallback(callback);
523 }
524
525 void WebEngine::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
526 {
527   GetImplementation(*this).RegisterConsoleMessageReceivedCallback(callback);
528 }
529
530 void WebEngine::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback)
531 {
532   GetImplementation(*this).RegisterResponsePolicyDecidedCallback(callback);
533 }
534
535 void WebEngine::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
536 {
537   GetImplementation(*this).RegisterCertificateConfirmedCallback(callback);
538 }
539
540 void WebEngine::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
541 {
542   GetImplementation(*this).RegisterSslCertificateChangedCallback(callback);
543 }
544
545 void WebEngine::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback)
546 {
547   GetImplementation(*this).RegisterHttpAuthHandlerCallback(callback);
548 }
549
550 void WebEngine::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback)
551 {
552   GetImplementation(*this).RegisterContextMenuShownCallback(callback);
553 }
554
555 void WebEngine::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback)
556 {
557   GetImplementation(*this).RegisterContextMenuHiddenCallback(callback);
558 }
559
560 void WebEngine::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
561 {
562   GetImplementation(*this).GetPlainTextAsynchronously(callback);
563 }
564
565 } // namespace Dali