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