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