Merge "Make not assert when file path is invalid." into devel/master
[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.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
32 #include <dali/internal/web-engine/common/web-engine-impl.h>
33
34 // EXTERNAL INCLUDES
35 #include <dali/public-api/images/pixel-data.h>
36
37 namespace Dali
38 {
39 WebEngine::WebEngine()
40 {
41 }
42
43 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
44 : BaseHandle(internal)
45 {
46 }
47
48 WebEngine::~WebEngine()
49 {
50 }
51
52 WebEngine WebEngine::New()
53 {
54   Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
55
56   return WebEngine(engine.Get());
57 }
58
59 WebEngine::WebEngine(const WebEngine& webEngine)
60 : BaseHandle(webEngine)
61 {
62 }
63
64 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
65 {
66   if(*this != webEngine)
67   {
68     BaseHandle::operator=(webEngine);
69   }
70   return *this;
71 }
72
73 WebEngine WebEngine::DownCast(BaseHandle handle)
74 {
75   return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
76 }
77
78 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
79 {
80   GetImplementation(*this).Create(width, height, locale, timezoneId);
81 }
82
83 void WebEngine::Create(int width, int height, int argc, char** argv)
84 {
85   GetImplementation(*this).Create(width, height, argc, argv);
86 }
87
88 void WebEngine::Destroy()
89 {
90   GetImplementation(*this).Destroy();
91 }
92
93 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
94 {
95   return GetImplementation(*this).GetNativeImageSource();
96 }
97
98 Dali::WebEngineSettings& WebEngine::GetSettings() const
99 {
100   return GetImplementation(*this).GetSettings();
101 }
102
103 Dali::WebEngineContext& WebEngine::GetContext() const
104 {
105   return GetImplementation(*this).GetContext();
106 }
107
108 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
109 {
110   return GetImplementation(*this).GetCookieManager();
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 const std::string& WebEngine::GetUrl()
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 std::string& 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(int deltaX, int deltaY)
209 {
210   GetImplementation(*this).ScrollBy(deltaX, deltaY);
211 }
212
213 bool WebEngine::ScrollEdgeBy(int deltaX, int deltaY)
214 {
215   return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
216 }
217
218 void WebEngine::SetScrollPosition(int x, int 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, std::function<void(const std::string&)> resultHandler)
259 {
260   GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
261 }
262
263 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> 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 void WebEngine::ClearHistory()
299 {
300   GetImplementation(*this).ClearHistory();
301 }
302
303 void WebEngine::ClearAllTilesResources()
304 {
305   GetImplementation(*this).ClearAllTilesResources();
306 }
307
308 const std::string& WebEngine::GetUserAgent() const
309 {
310   return GetImplementation(*this).GetUserAgent();
311 }
312
313 void WebEngine::SetUserAgent(const std::string& userAgent)
314 {
315   GetImplementation(*this).SetUserAgent(userAgent);
316 }
317
318 void WebEngine::SetSize(int width, int height)
319 {
320   GetImplementation(*this).SetSize(width, height);
321 }
322
323 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
324 {
325   GetImplementation(*this).SetDocumentBackgroundColor(color);
326 }
327
328 void WebEngine::ClearTilesWhenHidden(bool cleared)
329 {
330   GetImplementation(*this).ClearTilesWhenHidden(cleared);
331 }
332
333 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
334 {
335   GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
336 }
337
338 void WebEngine::EnableCursorByClient(bool enabled)
339 {
340   GetImplementation(*this).EnableCursorByClient(enabled);
341 }
342
343 std::string WebEngine::GetSelectedText() const
344 {
345   return GetImplementation(*this).GetSelectedText();
346 }
347
348 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
349 {
350   return GetImplementation(*this).SendTouchEvent(touch);
351 }
352
353 bool WebEngine::SendKeyEvent(const KeyEvent& event)
354 {
355   return GetImplementation(*this).SendKeyEvent(event);
356 }
357
358 bool WebEngine::SendHoverEvent( const HoverEvent& event )
359 {
360   return GetImplementation( *this ).SendHoverEvent( event );
361 }
362
363 bool WebEngine::SendWheelEvent( const WheelEvent& event )
364 {
365   return GetImplementation( *this ).SendWheelEvent( event );
366 }
367
368 void WebEngine::SetFocus(bool focused)
369 {
370   GetImplementation(*this).SetFocus(focused);
371 }
372
373 void WebEngine::SetPageZoomFactor(float zoomFactor)
374 {
375   GetImplementation(*this).SetPageZoomFactor(zoomFactor);
376 }
377
378 float WebEngine::GetPageZoomFactor() const
379 {
380   return GetImplementation(*this).GetPageZoomFactor();
381 }
382
383 void WebEngine::SetTextZoomFactor(float zoomFactor)
384 {
385   GetImplementation(*this).SetTextZoomFactor(zoomFactor);
386 }
387
388 float WebEngine::GetTextZoomFactor() const
389 {
390   return GetImplementation(*this).GetTextZoomFactor();
391 }
392
393 float WebEngine::GetLoadProgressPercentage() const
394 {
395   return GetImplementation(*this).GetLoadProgressPercentage();
396 }
397
398 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
399 {
400   GetImplementation(*this).SetScaleFactor(scaleFactor, point);
401 }
402
403 float WebEngine::GetScaleFactor() const
404 {
405   return GetImplementation(*this).GetScaleFactor();
406 }
407
408 void WebEngine::ActivateAccessibility(bool activated)
409 {
410   GetImplementation(*this).ActivateAccessibility(activated);
411 }
412
413 bool WebEngine::SetVisibility(bool visible)
414 {
415   return GetImplementation(*this).SetVisibility(visible);
416 }
417
418 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
419 {
420   return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
421 }
422
423 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
424 {
425   GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
426 }
427
428 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
429 {
430   return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
431 }
432
433 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
434 {
435   return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
436 }
437
438 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
439 {
440   return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
441 }
442
443 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
444 {
445   GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
446 }
447
448 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
449 {
450   GetImplementation(*this).UpdateDisplayArea(displayArea);
451 }
452
453 void WebEngine::EnableMouseEvents(bool enabled)
454 {
455   GetImplementation(*this).EnableMouseEvents(enabled);
456 }
457
458 void WebEngine::EnableKeyEvents(bool enabled)
459 {
460   GetImplementation(*this).EnableKeyEvents(enabled);
461 }
462
463 void WebEngine::EnableVideoHole(bool enabled)
464 {
465   GetImplementation(*this).EnableVideoHole(enabled);
466 }
467
468 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
469 {
470   return GetImplementation(*this).PageLoadStartedSignal();
471 }
472
473 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
474 {
475   return GetImplementation(*this).PageLoadInProgressSignal();
476 }
477
478 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
479 {
480   return GetImplementation(*this).PageLoadFinishedSignal();
481 }
482
483 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
484 {
485   return GetImplementation(*this).PageLoadErrorSignal();
486 }
487
488 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
489 {
490   return GetImplementation(*this).ScrollEdgeReachedSignal();
491 }
492
493 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
494 {
495   return GetImplementation(*this).UrlChangedSignal();
496 }
497
498 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
499 {
500   return GetImplementation(*this).FormRepostDecisionSignal();
501 }
502
503 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
504 {
505   return GetImplementation(*this).FrameRenderedSignal();
506 }
507
508 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
509 {
510   return GetImplementation(*this).RequestInterceptorSignal();
511 }
512
513 Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMessageSignal()
514 {
515   return GetImplementation(*this).ConsoleMessageSignal();
516 }
517
518 Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& WebEngine::PolicyDecisionSignal()
519 {
520   return GetImplementation(*this).PolicyDecisionSignal();
521 }
522
523 Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::CertificateConfirmSignal()
524 {
525   return GetImplementation(*this).CertificateConfirmSignal();
526 }
527
528 Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::SslCertificateChangedSignal()
529 {
530   return GetImplementation(*this).SslCertificateChangedSignal();
531 }
532
533 Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& WebEngine::HttpAuthHandlerSignal()
534 {
535   return GetImplementation(*this).HttpAuthHandlerSignal();
536 }
537
538 } // namespace Dali